all bits zero?

bdm659 at csc.anu.oz bdm659 at csc.anu.oz
Fri Mar 23 02:51:01 AEST 1990


In article <1217 at sdrc.UUCP>, scjones at sdrc.UUCP (Larry Jones) writes:
> 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?
>
> ANSI C requires a pure binary numeration system for all integral
> types, so "yes".
[... and similar answers from lots of other people]

I think you are all wrong.  The implementation must only behave *as if*
integral types are represented in binary.  Integers might in fact be
stored in packed-decimal or something; if conforming programs can't
tell the difference, it doesn't matter.  Such an implementation is
going to have to work hard to do bitwise operations, for example, but
that's not the issue.

I think the correct answer to the original question is:  "Zero can be
stored any way the compiler-writer felt like it.  However, you won't
be able to write an ANSI-conforming program which can tell that it isn't
stored in binary with all bits zero."

Brendan McKay.   bdm at anucsd.oz.au  or  bdm659 at csc1.anu.oz.au



More information about the Comp.std.c mailing list