One's complement machines and C logic

Steven M. Haflich smh at mit-eddie.UUCP
Sun Jan 29 01:19:00 AEST 1984


Back in 1959 a small, young computer company released a new machine, the
Programmed Data Processor 1 (PDP1).  It is (at least one is still
running!) an 18-bit, ones-complement machine.  It also had hardware
multiply and divide, although that may have been an option and may have
appeared later than the original machine.

The instruction manual clearly states that the *only* arithmetic
operation yielding minus zero is the addition: (+0)+(-0) ==> (-0).
(This supports the notion that addition of (+0) is as much an identity
operation as an arithmetic operation.)  Even in the dark ages, when
gates were expensively built of discrete transitors, it was still
possible to do things right.

Next item:  The problem of multiple representations for zero is not
unique to ones-complement.  Most floating point representations employ
a separate sign bit, i.e., sign-magnitude.  It is possible to write (-0)
as a constant, but floating instructions generally will not produce it.
Indeed, the PDP11 provides hardware support for trapping when the FPU
fetches (-0).  This allows cost-free execution-time checking for
computations on uninitialized variables.

Steve Haflich, MIT Experimental Music Studio



More information about the Comp.lang.c mailing list