[U-Boot-Users] printf question

Pantelis Antoniou panto at intracom.gr
Wed Mar 24 09:18:58 CET 2004


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






More information about the U-Boot mailing list