[comp.lang.c] Zero on ones cmplement machines

g-rh@cca.CCA.COM (Richard Harter) (07/14/87)

It's been a long time since I was working on a CDC 6600, but I did a
fair bit of work on them.  There were a number of ways in which you
could get -0, and I do recall that there were some applications where
you needed the following bit of arcane FORTRAN:

	IF (INTVAL.EQ.0) INTVAL=0

if you needed to ensure that INTVAL had +0 instead of -0.  If I am
not mistaken you could get a negative 0 by negation and also that you
could get it via floating point underflow.

My recollection is that the 6600 did not have integer arithmetic instructions
-- all arithmetic was done in floating point!  [It also had one of the more
unusual machine architectures that I have ever seen.]

The most startling bug I ever encountered was on that machine.  I was
working on a program which used a bit map.  It wasn't working right.  I
put in a bunch of print statements to try to locate the problem area.
Every time I put in a statement the problem moved around, and sometimes
the printed results changed.  Then came the moment when I printed out
the octal contents of a word, using an O21 format, 20 for the 60 bit
word and 1 for a space.  The machine printed a 21 octal digit number,
corresponding to a 61 bit number!  I decided that my program,
however buggy it might be, could not alter the architecture of the
machine.  It turned out that there was an indexing error in the bit
map manager that was randomly changing bits, one at a time, in the
FORTRAN I/O routines at random locations.

Apologies, not much to do with C, but I though it might be interesting.
-- 

Richard Harter, SMDS Inc. [Disclaimers not permitted by company policy.]
			  [I set company policy.]