07-02-2012
Glad you figured that out. I was in the process of replying and when I refreshed saw your addition.
The warning must be a C++ thing; I'm a C person, so that construct makes sense to me. Not sure how to get rid of it.
It is not necessary to shift both values
The subtraction in the code is a quick way to convert a digit represented in ASCII to a value. The numbers 0 through 9 have ASCII values 0x30, 0x31... 0x39. If the input value on the command line is "42" argv[x] points to two bytes: 0x34 0x32. To convert the first character (4) into an integer 4, you can subtract the value of the character zero from it (0x34 - 0x30) which yields 4. You would do the same for the values A-F and a-f to convert the ASCII representation of the hex digit to a value.
Yes, it is necessary to shift the value in val by 4 bits each time you add in a digit. Lets assume "123" was entered on the command line. The first time through the loop val is 0 and the shift has no effect. The character '1' is converted to integer and added to val; val becomes 1.
The second time through the loop val is shifted and becomes 0x10. The character '2' is converted to integer and then is added to val which now holds the value 0x12.
Again val is shifted and bcomes 0x120. The '3' is converted and added to val leaving the variable with 0x123.
Think of it as sliding the digits over one nibble to the left to make room for the next value.
Hope that makes some sense.
This User Gave Thanks to agama For This Post:
8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi!
What is the way to get the binary representation of a IEEE 754 (like 0001110110001111010101100111001011100100101010111101) without using perl. Bash for example, would be fine.
I need to put that representation in a string for some operation and then to put that string back in a float.
... (3 Replies)
Discussion started by: Zephyr
3 Replies
2. Programming
I came across a puzzle which I can not explain. The setup is SCO OpenServer 5.7 (32 bit OS) and native SCO compiler. double is 8 bytes long on this system. I am able to populate the double variable with two different sets of values that produces the same double value, please see below:
#include... (7 Replies)
Discussion started by: migurus
7 Replies
3. Shell Programming and Scripting
Hello friends,
Is there any way to split file from n to n+6 into 1 file and (n+7) to (n+16) into other file etc.
f.e I have source pipe delimated file with 20 lines and i need to split 1-6 in file1 and 7-16 in file2 and 17-20 in file 3
I need to split into fixed number of file like 4 files... (2 Replies)
Discussion started by: Rizzu155
2 Replies
4. Shell Programming and Scripting
Hi, consider a file which has data such as
"random text",912345,"54","finish"
"random text",9991236745,"9954","finish"
I want to replace the numbers that don't have double quotes around them with ones that do; so the output should be
"random text","912345","54","finish"
"random... (4 Replies)
Discussion started by: Storms
4 Replies
5. Shell Programming and Scripting
Dear All,
I have to split a tab delimited file in two files based on the presence of a positive or negative in column number 9 , for example
file:
A 1 5 erg + 6766 0.9889 0.9817 9.01882 erg inside upstream
B 1 8 erg2 + 6766 0.9889 0.9817 -9.22 erg2 inside... (3 Replies)
Discussion started by: paolo.kunder
3 Replies
6. Shell Programming and Scripting
Hello *nix specialists,
Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies
7. Programming
I have an assignment in which a character is the input of which some bits(from a position to certain position) are to be inverted (1's complement) and then the resultant character is to be returned....for example
unsigned char x = J from p = 3 to offset n = 5
01001010 inverted to... (1 Reply)
Discussion started by: ezee
1 Replies
8. UNIX for Beginners Questions & Answers
I have a file that is pipe delimited and in Column F they have number values, both positive and negative. I need to take the one file I am starting with and split it into two separate files based on negative and positive numbers. What is the command to do so? And then I need to also transfer... (4 Replies)
Discussion started by: cckaiser15
4 Replies
LEARN ABOUT FREEBSD
debconf-mergetemplate
DEBCONF-MERGETEMPLATE(1) Debconf DEBCONF-MERGETEMPLATE(1)
NAME
debconf-mergetemplate - merge together multiple debconf template files
SYNOPSIS
debconf-mergetemplate [options] [templates.ll ...] templates
DESCRIPTION
Note: This utility is deprecated. You should switch to using po-debconf's po2debconf program.
This program is useful if you have multiple debconf templates files which you want to merge together into one big file. All the specified
files will be read in, merged, and output to standard output.
This can be especially useful if you are dealing with translated template files. In this case, you might have your main template file, plus
several other files provided by the translators. These files will have translated fields in them, and maybe the translators left in the
english versions of the fields they translated, for their reference.
So, you want to merge together all the translated templates files with your main templates file. Any fields that are unique to the
translated files need to be added in to the correct templates, but any fields they have in common should be superseded by the fields in the
main file (which might be more up-to-date).
This program handles that case properly, just list each of the translated templates files, and then your main templates file last.
OPTIONS
--outdated
Merge in even outdated translations. The default is to drop them with a warning message.
--drop-old-templates
If a translation has an entire template that is not in the master file (and thus is probably an old template), drop that entire
template.
SEE ALSO
debconf-getlang(1)
AUTHOR
Joey Hess <joeyh@debian.org>
2012-09-10 DEBCONF-MERGETEMPLATE(1)