[net.arch] One's complement damage through software

stuart@rochester.UUCP (Stuart Friedberg) (02/02/84)

Someone mentioned that on CDC machines the only way to get a -0 is by
complementing a +0. This is a story of what can happen when the
hardware (CDC6600/6700) is reasonable but system software is somewhat
brain damaged.

I wrote a CAI lession for the PLATO system run by the University of
Illinois which plotted direction fields for differential equations. I
did a lot of atan2 calls to determine at which angle to draw little
directed arrows. Now, atan2 determines which quadrant its result falls
in based on the SIGNS of BOTH arguments. I started getting some very
strange results when all my arrows pointed in the right directions
except those supposed to point straight up.  They pointed down
instead.

The problem was that one of the arguments to atan2 was -0 instead of
+0. Where did it come from? Well, the TUTOR language in which all
these CAI lessons was/is written is primarily interpreted and the
PLATO systems people had decided to implement an arithmetic negate
as a logical complement. If I remember correctly, the reason given
was efficiency. One of my expression had a negated term in it and
happened to be zero in lots of reasonable cases.

By the way, this is not intended as a flame at the UofI or the people
who worked, work or will work on PLATO there. I had a lot of non-
productive fun on that system. Anyone out there remember EMPIRE, SPASM
or PHOENIX3?

				Stu Friedberg
				stuart@rochester	ARPA
		{seismo, allegra}!rochester!stuart	UUCP