Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!swlabs!jack From: jack@swlabs.UUCP (Jack Bonn) Newsgroups: comp.lang.c Subject: Re: NULL, zero, and readable code Message-ID: <266@swlabs.UUCP> Date: Thu, 9-Jul-87 20:10:58 EDT Article-I.D.: swlabs.266 Posted: Thu Jul 9 20:10:58 1987 Date-Received: Sun, 12-Jul-87 06:59:48 EDT References: <8170@brl-adm.ARPA> <13222@topaz.rutgers.edu> <6090@brl-smoke.ARPA> Organization: Software Labs, Ltd. Easton CT USA Lines: 45 In article <6090@brl-smoke.ARPA>, gwyn@brl-smoke.ARPA (Doug Gwyn ) writes: > In article <13222@topaz.rutgers.edu> ron@topaz.rutgers.edu (Ron Natalie) writes: > >What does ANSI C say about -0 on ones complement machines? > > 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 I don't believe this to be the case. One's complement addition is the same as two complement addition with the addition of END AROUND CARRY. This means that the carry is brought around to the lsb and added in. Perhaps an example will elucidate for those less familiar with the technique. Lets assume a 16 bit word for simplicity. hex decimal comments FFFE -1 Negation is simply complementation in one's comp. +0001 1 Same as two's comp for numbers > 0. =FFFF -0 Sum of the above. Note that no carry was generated, so the END AROUND rule doesn't apply. Note that we generated a -0 when none of the original operands were -0. Now an example with a carry: hex decimal comments FFFE -1 Negation is simply complementation in one's comp. +0002 2 Same as two's comp for numbers > 0. =C0000 Sum of the above. Carry was generated so the END AROUND rule applies. Note that that this is an intermediate result and would never be made available. =0001 1 Result. The carry is added in before the result is made available. I don't know whether ALL machines will leave a -0 result. But I know that the CDC 6400 (and family) did. Since the one's complement system was claimed to be used for speed, I doubt that many manufacturers would add an additional normalization step before storing results. Do you have any examples of machines that do this normalization? Anyway, is the CDC family to be dismissed as un"reasonable"? -- Jack Bonn, <> Software Labs, Ltd, Box 451, Easton CT 06612 seismo!uunet!swlabs!jack