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

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



Torsten Landschoff <torsten@debian.org> writes:

> On Sun, Jan 13, 2002 at 10:23:51PM -0800, elf@florence.buici.com wrote:
> > Moreover, the original depends on the fact that (MAX_INT + 1) < 0
> > which, though true, is a guaranteed result.  Were I to be running a 64
> 
> ... is not a guaranteed ...
> 
> I yet have to see a machine that does not use two's complement
> for integer arithmetic.

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.

Thomas



Reply to: