Print a short instead of an int... ? What's up with "%hd"?




When passing arguments to a VAL function, all integer types are
promoted, and floats become doubles. Therefore, signed short will be
promoted to signed int. Therefore I can't see any reason why you'd
have:

printf( "%hd", my_short);

instead of:

printf( "%d", my_short);


Martin

.



Relevant Pages

  • Re: Print a short instead of an int... ? Whats up with "%hd"?
    ... promoted, and floats become doubles. ... promoted to signed int. ... Therefore I can't see any reason why you'd ... but makes a difference in the scanning process. ...
    (comp.lang.c)
  • Re: The difference between signed and unsigned when doing `mod
    ... >> If signed int on your platform can hold all the values of an unsigned ... >> ranking integer types, these promotions sometimes result in signed ... >> values of the higher types. ... Jack Klein ...
    (comp.lang.c)
  • Re: The difference between signed and unsigned when doing `mod
    ... 'a' and 'b' will be promoted to signed int for the subtraction. ... When dealing with promotions of unsigned integer types to higher ... values of the higher types. ...
    (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: Compiler-extension small int type promotion
    ... promotion to become a "signed int". ... Standard for couple of minutes but I'm not certain. ... Extensions are not covered by the standard. ... extended integer types fit in with the others. ...
    (comp.lang.c)