I have the hex value 0x5a800000000b and I’m trying to get a printf statement in C to print it to the console.
So far (because I’m useless in C) I’m able to get the ‘b’ to print, using the syntax:
printf("Hex value%x\n", value);
The value is stored in an integer type U32, but after trying all different combinations of %llx, %lx, I just keep getting compiler warnings.
I’m guessing that I’m getting the printf syntax wrong, but I can’t seem to find the right % option, can someone help me out?
Thanks
It’s not a problem with the
printf.The problem is that a 32 bits variable cannot hold the value
0x5a800000000b. 32 bits can hold only 8 hex digits: 0x0000000b. Hence thebon output.To store such a large value, you should use a 64 bits variable.
Note also the double
Lat the end. It tells the compiler that the constant is also along long.Then you can use
%llxin theprintfformat string.