Newsgroups: comp.arch From: hoey@zogwarg.etl.army.mil (Dan Hoey) Date: 27 Nov 92 18:29:18 GMT Subject: Re: Summary: Integers implementation fa...@gr.osf.org (Christian Fabre) writes: >For integers arithmetics, 2's complement is the most >used nowdays with a BIG advantage over 1's complement and >sign-magnitude: only one representation of 0. Another >advantage is that size extension is more [convenient]. Actually, it's more that sign extension makes sense. Which is to say that converting an n-bit twos-complement number to an m-bit number, the low-order min(m,n) bits don't change. So the sign bit does not usually require a lot of extra logic. >1's complement was used (e.g. PDP11, CDC), buts its advantage >of fast negation and symetrical ranges around zero does not >balance the 2 zero problem. The PDP-11 used twos complement. But another use of ones complement is in checksum calculations. I think the advantage is that if you want to find the ones-complement sum of a bunch of n-bit bytes, you can add them up k at a time as a bunch of kn-bit bytes, and then add together the k n-bit bytes in the sum. This saves time when your machine has wide instructions. >sign-magnitude and excess-n are used to represent floating >points number (mantissa and exp, respectively). I'm pretty sure twos complement is often used for the mantissa, too. Excess-n, where n = 2^(# bits - 1), is just twos complement with the top bit complemented. I recall that with a twos complement mantissa and an excess-n exponent, you can use twos complement integer comparisons on floating point numbers. As far as I know, that's the only reason to favor excess-n over twos complement for the exponent. Dan Hoey Hoey@AIC.NRL.Navy.Mil