Binary Number System: Representations | |
Offset Signed Binary Integer Begin with the number to be encoded.The examples, below, show how this technique would be used to represent -127, -85, 0, +42 and +127 in 8-bit offset: Both sign-magnitude and offset representations have a significant limitation. They cannot be used reliably for mathematical manipulation. Consider, for example, the 8-bit sign-magnitude representations for +1 and -1. Clearly these two values should add up to zero, but they do not:value value to after be encoded offset encoding -127 + 127 = 0 = 00000000 -85 + 127 = 42 = 00101010 0 + 127 = 127 = 01111111 +42 + 127 = 169 = 10101001 +128 + 127 = 255 = 11111111 According to this, +1 plus -1 equals -2. Wrong! Note that binary math works just like decimal math, but with fewer digits. In other words, all we need to remember is 0+0=0, 0+1=1, and 1+1=0, carry the 1.00000001 = +1 in sign-magnitude + 10000001 = -1 ---------- 10000010 = -2 Likewise, offset representations won't work: Again, we get silly answers: +1 plus -1 equals +127. A system of signed binary numbers must allow us to do binary math correctly. The following representation fits that requirement.10000000 = +1 in 127-offset + 01111110 = -1 ---------- 11111110 = +127 Next Page |