Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!gatech!hao!noao!arizona!gmt
From: gmt@arizona.edu (Gregg Townsend)
Newsgroups: comp.lang.c
Subject: Re: NULL, zero, and readable code
Message-ID: <1807@megaron.arizona.edu>
Date: Fri, 10-Jul-87 01:59:49 EDT
Article-I.D.: megaron.1807
Posted: Fri Jul 10 01:59:49 1987
Date-Received: Sun, 12-Jul-87 10:42:15 EDT
References: <8170@brl-adm.ARPA> <13222@topaz.rutgers.edu> <6090@brl-smoke.ARPA> <266@swlabs.UUCP>
Organization: U of Arizona CS Dept, Tucson
Lines: 29
Summary: How to avoid gratuitous -0 on 1's comp machine; CDC 6000s did this.

In article <6090@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes:
>                                              Note that on reasonable 1's
> complement architectures, one does not get a -0 as the result of a series
> of arithmetic operations unless one of the original operands were -0
 
In article <266@swlabs.UUCP>, jack@swlabs.UUCP (Jack Bonn) replies:
> I don't know whether ALL machines will leave a -0 result.  But I know
> that the CDC 6400 (and family) did....  Do you have any examples that
> [normalize to avoid this]?  Anyway, is the CDC family
> to be dismissed as un"reasonable"?

I programmed the CDC 6000 series in assembly language for 12 years.  For an
addition, both operands had to be -0 to get a -0 result;  for subtraction it
had to be  (-0) - (+0).  I don't remember if you could even get -0 from integer
multiplication, but that wasn't in the original architecture anyway.

The way to think of this was that both operands of addition, or the wrong
one for subtraction, were complemented (negated) and then added.  Then the
result was complemented on the way out.  I assume this was just conceptual
and actually involved negative logic instead of extra gates.

So the example of (-1) + (+1) becomes	(sorry, I still think in octal!)
	-1  =  7776   compl ->  0001
	+1  =  0001   compl ->  7776
				----
			add ->	7777	compl -> 0000	yielding +0 result

     Gregg Townsend / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
     +1 602 621 4325      gmt@Arizona.EDU       110 57 17 W / 32 13 47 N / +758m