signed/unsigned char/short/int/long [was: #defines with parameters]

Jerry Schwarz jss at hector.UUCP
Tue Nov 29 07:42:39 AEST 1988


In article <277 at aber-cs.UUCP> pcg at cs.aber.ac.uk (Piercarlo Grandi) 
makes some groundless attacks on the ANSI commitee apparently
due to misunderstanding the (proposed) standard.  I respond to
one case in which either he or I have clearly misunderstood something.

>
>Using this interpretation, there is little argument about adopting a
>"[un]signed preserving" or "value preserving" rule; the only rules are
>that conversion from a shorter to a long form of the same type results
>in no changes, and tyhe same applies when a longer value is shortened
>to a length that can represent it, and conversion across the two base
>types is defined only if the source unsigned is not too large or the
>source int is not too large or negative; anything else is machine
>dependent, except that truncations to a length of unsigned must respect
>the rules of modular arithmetic.

This is pretty much what the standard says about conversions, but it
in no way resolves the difference between the "value preserving" and
"unsigned preserving" rules.  These address a different question.
Namely the types of certain expressions.  For example what is the
type of i+us (where i is an int, and us is an unsigned short).


Jerry Schwarz
AT&T Bell Labs, Murray Hill



More information about the Comp.lang.c mailing list