Re: Printf question.



"Flash Gordon" <spam@xxxxxxxxxxxxxxxxxx> wrote
>
>> Correction: since a signed int can hold any value of type unsigned
>> char, the value in the unsigned char 'a' is promoted to type int.
>
> <annoying pedant>
> What, even on a system with CHAR_BIT==16 and sizeof(int)==1 ?
> </annoying pedant>
>
> Of course, you are only likely to find such systems in the embedded world
> where you may well not have printf.
>
But often you have vsprintf(), or you need to implement it.

The whole language does begin to break down when we push the limits of
ANSI's definition. For instance, should field-length parameters really be
size_t s?



.



Relevant Pages

  • Re: ones complement of unsigned char
    ... Does it mean that since the operand is unsigned, the promoted type is ... x is promoted to unsigned int before applying operator ~. ... 'x' is promoted to signed int, ... into on this platform can hold all values of unsigned char. ...
    (comp.lang.c)
  • Re: Quick check on signed promotion of bytes
    ... Eric Sosman: ... The complement is take of this signed int. ... The signed int is converted to an unsigned char. ...
    (comp.lang.c)
  • Re: Quick check on signed promotion of bytes
    ... Tomás Ó hÉilidhe wrote: ... The complement is take of this signed int. ... What we _want_ this code to do is to give us the value 0x0f for y (i.e. the complement of x). ... The signed int is converted to an unsigned char. ...
    (comp.lang.c)
  • Re: Printf question.
    ... >> In the case of integer types of lesser rank than int, ... >> promotions" occur. ... Since a signed int can hold the value 200, ... the value in the unsigned char 'a' is promoted to type int. ...
    (comp.lang.c)
  • Re: convert argv[1] to hex
    ... reinvent strtol() unnecessarily? ... "Your correction is 100% correct and 0% helpful. ... unsigned char variable, ...
    (comp.lang.c)