all bits zero?

Karl Heuer karl at haddock.ima.isc.com
Thu Mar 22 04:49:17 AEST 1990


In article <2108 at gmdzi.UUCP> wittig at gmdzi.UUCP (Georg Wittig) writes:
>Does ANSI C require that in the internal representation of the integer
>constant ``0'' all bits are zero?

Assuming it's not in a pointer context--in which case it would have been a
null pointer constant, not an integer constant, despite having the same
spelling--yes.  Non-negative integers, signed or unsigned, whether formed by
constants of any radix or by run-time expressions, are required to be
represented in a "pure binary system".  Without such a guarantee, the bitwise
operators would be much less useful.

Much less is said about negative integers.  The value -1 looks like 1111 in
two's complement, 1110 in one's complement, and 1001 in sign-magnitude.  All
of these (and presumably even stranger things) are legal; in the latter two
cases a conversion from signed int to unsigned int actually entails a change
in the bit-pattern (since (unsigned)-1 == UINT_MAX which looks like 1111).

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.std.c mailing list