Printf and hex values
14,695
My guess is that value
is 8. :-)
Are you on a little endian machine, such as x86? I'm going to guess that by be16
you mean that the value is big endian and you need to swap the bytes.
Comments
-
mamidon almost 2 years
So, I have a value of type __be16 (2 bytes). In hex, the value is represented as 0x0800 or 2048 in decimal. (16^2 * 8)
So, when I printf this; I do this:
printf("%04X", value); //__be16 value; //Print a hex value of at least 4 characters, no padding.
output: 0008
printf("%i", value); //Print an integer.
output: 8
I should be getting 0800 and 2048 respectively, what am I doing wrong?