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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.