BSD bzero() & NULL

Richard Tobin richard at aiai.ed.ac.uk
Fri Nov 16 02:58:10 AEST 1990


In article <RJC.90Nov15073451 at brodie.uk.ac.ed.cstr> rjc at uk.ac.ed.cstr (Richard Caley) writes:
>Does the standard demand that the bit pattern for then integer 0 be
>`all zeros'.

3.1.2.5 (Types):

  The representation of integral types shall define values by use of a
  pure binary numeration system.

  [A footnote defines this as: A positional representation for
  integers that uses the binary digits 0 and 1, in which the values
  represented by successive bits are additive, beginning with 1, and
  are multiplied by successive integral powers of 2, except perhaps
  the bit with the highest position.]

In other words, yes.  Or at least that's what they mean.  I don't
actually see anything that stops a system that's 2s-complement with
the meaning of the sign bit reversed.  I suppose it depends on the
scope of the "except".

The intention is to allow 2s and 1s complement.

>Obviously all the standard operation would have to work (the bitwise
>ones would be the killer). 

Section 3.3 (Expressions) specifically notes:

  These [bitwise] operators return values that depend on the internal
  representations of integers, and thus have implementation-defined
  aspects for signed types.

>The only real way to tell the difference
>would be to write some data raw to file and read it using some other
>system. 

Since nothing is guaranteed about the external representation of data
written to binary streams, you can't even do this.  By the "as if"
rule, the hardware could use ternary Gray code, so long as the
compiler made the operators do the right thing.  And if it did,
there's nothing to stop it converting to and from 2s complement when
doing binary i/o.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.lang.c mailing list