[U-Boot-Users] printf question
Wolfgang Denk
wd at denx.de
Thu Mar 25 21:49:40 CET 2004
In message <54305.216.110.51.8.1080245554.squirrel at www.orkun.us> you wrote:
>
> > But we agree that the conversion "unsigned char" ==> "unsigned int"
> > must result in exactly the same result, no matter if done implicitely
> > or by explicit cast?
...
> I agree, unsigned char should be promoted to unsigned int.
Must, not should.
> However, char can be unsigned or signed depending on the platform. On a
But the variable in question was of type "unsigned char", which
leaves no room for implementation-specific behaviour.
> before passing it to printf. So, a value like 0xC2 (-62 as 8-bit value)
We are talking about a format element which expects an "unsigned int"
argument, and an "unsigned char" argument. There was no constant
expression involved.
> with twos complement arithmetic. %02X can only suppress leaving zeros so
> additional f's will be printed.
Oops? %02X will _add_ leading zeroes if the result is too short, but
it will never supress anything.
[Maybe we should take this to c.l.c ;-)]
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd at denx.de
8 Catfish = 1 Octo-puss
More information about the U-Boot
mailing list