[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please don't do this (code fragment)



elf@florence.buici.com writes:

> According to every reference I have found, there is no stipulation
> that integers be implemented using two's complement notation.  IIRC,
> some of the Cray computers represented integers with a sign bit.  I
> doubt the claim.

You don't read very well.  What I said originally was:

 Actually, the C standard does essentially guarantee two's complement
 arithmetic.  It specifies integer overflow behavior and
 signed/unsigned conversion behavior exactly.

 So a machine can do its arithmetic some other way, but it has to make
 it seem to the programmer that it's always two's complement.

Note carefully the distinction between implementation and appearance
to the programmer.

Further posts on the thread have corrected my faulty memory; not quite
as much is specified as I thought.  (In particular, overflow behavior
is not specified.)  But signed/unsigned conversion *is* so specified.

Thomas



Reply to: