Hardware Reference
In-Depth Information
1 1110110111
1+2×1499 = 2999
Result
1+2×749=1499
1+2×374=749
0+2×187=374
1+2×93=187
1+2×46=93
0+2×23=46
1+2×11=23
1+2×5=11
1+2×2=5
0+2×1=2
1+2×0=1
Start here
Figure A-6. Conversion of the binary number 101110110111 to decimal by suc-
cessive doubling, starting at the bottom. Each line is formed by doubling the one
below it and adding the corresponding bit. For example, 749 is twice 374 plus
the 1 bit on the same line as 749.
to the result. Binary addition is the same as decimal addition except that a carry is
generated if the sum is greater than 1 rather than greater than 9. For example, con-
verting 6 to two's complement is done in two steps:
00000110 (+6)
11111001 (
6 in one's complement)
6 in two's complement)
If a carry occurs from the leftmost bit, it is thrown away.
The fourth system, which for m -bit numbers is called excess 2 m 1 , represents a
number by storing it as the sum of itself and 2 m − 1 . For example, for 8-bit numbers,
m
11111010 (
8, the system is called excess 128 and a number is stored as its true value plus
128. Therefore,
=
3 is represented by the 8-bit bi-
nary number for 125 (01111101). The numbers from
3 becomes
3
+
128
=
125, and
128 to +127 map onto 0 to
255, all of which are expressible as an 8-bit positive integer. Interestingly enough,
this system is identical to two's complement with the sign bit reversed. Figure A-7
gives examples of negative numbers in all four systems.
Both signed magnitude and one's complement have two representations for
zero: a plus zero, and a minus zero. This situation is undesirable. The two's com-
plement system does not have this problem because the two's complement of plus
zero is also plus zero. The two's complement system does, however, have a dif-
 
 
Search WWH ::




Custom Search