Digital Signal Processing Reference
In-Depth Information
Table 3.3 Four-bit representation of two's complement number and its equivalent unsigned number
Decimal number
Two's complement representation
Equivalent unsigned
number
2 2
2 1
2 0
2 3
0
0
0
0
0
0
þ 1
0
0
0
1
1
þ 2
0
0
1
0
2
þ 3
0
0
1
1
3
þ 4
0
1
0
0
4
þ 5
0
1
0
1
5
þ 6
0
1
1
0
6
þ 7
0
1
1
1
7
8
1
0
0
0
8
7
1
0
0
1
9
6
1
0
1
0
10
5
1
0
1
1
11
4
1
1
0
0
12
3
1
1
0
1
13
2
1
1
1
0
14
1
1
1
1
1
15
3.3.4 Scaling
While implementing algorithms using finite precision arithmetic it is sometimes important to avoid
overflow as it adds an error that is equal to the complete dynamic range of the number. For example, the
case 7
4 0 b1000 as a 4-bit signed number is
8. To avoid overflow, numbers are scaled down.
In digital designs it is sometimes also required to sign extend an N-bit number to an M-bit number for
M
þ
1
¼
8
¼
>
N.
3.3.4.1 Sign Extension
In the case of a signed number, without affecting the value of the number, M
N bits are sign
extended. Thus a number can be extended by any number of bits by copying the sign bit to extended
bit locations. Although this extension does not change the value of the number, its unsigned
equivalent representation will change. The new equivalent number will be:
2 M jj
ð
3
:
5
Þ
Example: The number 2 as a 4-bit binary number is 4 0 b1110. As an 8-bit number it is
8 0 b11111110.
3.3.4.2 Scaling-down
When a number has redundant sign bits, it can be scaled down by dropping the redundant bits. This
dropping of bits will not affect the value of the number.
Example: The number - 2 as an 8-bit two's complement signed number is 8 0 b11111110. There are
six redundant sign bits. The number can be easily represented as a 2-bit signed number after throwing
away six significant bits. The truncated number in binary is 2 0 b10.
Search WWH ::




Custom Search