
24 Mar
2004
24 Mar
'04
9:18 a.m.
Jerry Walden wrote:
Okay - so this is probably not a big deal, however when I use the printf in u-boot as follows:
unsigned char x = 0xC2;
printf("this is the problem %02X\n", x);
result is:
this is the problem FFFFFFFC2
On most systems any datum of size less than int is implicitly converted to int when passed to a varargs function such as printf.
Char is typically signed so the conversion of any char with the 7 bit set will result in a negative integer.
0xC2 -> 0xFFFFFFFFC2.
To solve it just and with 0xFF.
Regards
Pantelis