|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integers: excess/bias |
|
|
|
|
One disadvantage of 2C: |
|
|
|
|
Can't sort values just
using the bit representation. |
|
|
|
Would look like negative
numbers were greater than positive numbers. |
|
|
Another
idea: |
|
|
|
|
Consider the unsigned
values for a 3-bit representation |
|
|
|
representation |
value |
|
excess-4 |
|
|
|
000 |
|
0 |
|
-4 |
|
|
|
|
001 |
|
1 |
|
-3 |
|
|
|
|
010 |
|
2 |
|
-2 |
|
|
|
|
011 |
|
3 |
|
-1 |
|
|
|
|
100 |
|
|
4 |
|
0 |
|
|
|
|
101 |
|
5 |
|
1 |
|
|
|
|
110 |
|
6 |
|
2 |
|
|
|
|
111 |
|
7 |
|
3 |
|
|
|
|
Represent negative
values, but keep the values in representation order |
|
|
|
First half of the
representations for negative, second half for positive |
|
|
|
This is called excess, or
biased, representation. |
|
|
|
|
Each value is shifted by
a constant amount; in this case the bias is 4. |
|
|
|
Since there are 3 bits,
the bias value is 2(3-1) = 4 |
|
|
|
|
In general, for an N-bit representation, we will have half
of the values negative |
|
|
and half of the values
non-negative if the bias is 2N-1. |
|
|
|
However, the bias could
be any number < 2N - 2 |
|
|
|
if the range of values
includes both positive and negative numbers. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|