Concept

Why does sign-magnitude representation lose one value of expressive power?

Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk / Chapter 1

"− 127. If you have sharp eyes, you may have noticed a discrepancy in the counting. With the sign-magnitude approach, we can hold numbers in the range − 127 to 127. But wait: that’s only 255 different values, not 256! Why did we lose one value of expressive power? The answer is that the sign-magnitude scheme has two ways of representing zero. The bit pattern 00000000 is obviously zero, but so is 10000000 (which you might call “negative zero.”) Using two different patterns to represent the same value is a little wasteful, but the situation is actually worse than that. Having to account for both patterns means that computer hardware using the sign-magnitude scheme is inevitably more complicated. To compare two bytes to see if they’re equal, you’d think we’d just compare each bit position, and if they were all the same, the bytes would be declared equal, otherwise no. Alas, this is no longer quite that simple. The two zero patterns must be considered numerically equal, so our digital logic now has to contain a special case. “To be equal, all the bits have to be the same…oh, but actually not if the right-most seven are all zeroes in both bytes. In that case, it doesn’t matter what the left-most bit contains.” Maddening."

Related Ideas

Why does sign-magnitude representation lose one value of expressive power? | Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk | Bifalgorithm | Bifalgorithm