Hardware Reference
In-Depth Information
octal-to-binary except that each hexadecimal digit corresponds to a group of 4 bits
instead of 3 bits. Figure A-4 gives some examples of conversions.
Example 1
.
.
.
1
9
4
8
B
6
Hexadecimal
0001100101001000 101101100
Binary
1
4
5
1
0
55
4
Octal
Example 2
.
.
.
Hexadecimal
7
B
A
3
B
C
4
Binary
0111101110100011 101111000100
Octal
7
5
6
4
3
5
7
0
4
Figure A-4. Examples of octal-to-binary and hexadecimal-to-binary conversion.
Conversion of decimal numbers to binary can be done in two different ways.
The first method follows directly from the definition of binary numbers. The
largest power of 2 smaller than the number is subtracted from the number. The
process is then repeated on the difference. Once the number has been decomposed
into powers of 2, the binary number can be assembled with 1s in the bit positions
corresponding to powers of 2 used in the decomposition, and 0s elsewhere.
The other method (for integers only) consists of dividing the number by 2.
The quotient is written directly beneath the original number and the remainder, 0
or 1, is written next to the quotient. The quotient is then considered and the proc-
ess repeated until the number 0 has been reached. The result of this process will be
two columns of numbers, the quotients and the remainders. The binary number
can now be read directly from the remainder column starting at the bottom. Figure
A-5 gives an example of decimal-to-binary conversion.
Binary integers can also be converted to decimal in two ways. One method
consists of summing up the powers of 2 corresponding to the 1 bits in the number.
For example,
10110
2 4
2 2
2 1
22
In the other method, the binary number is written vertically, one bit per line, with
the leftmost bit on the bottom. The bottom line is called line 1, the one above it
line 2, and so on. The decimal number will be built up in a parallel column next to
the binary number. Begin by writinga1online 1. The entry on line n consists of
two times the entry on line n
=
+
+
=
16
+
4
+
2
=
1 plus the bit on line n (either 0 or 1). The entry on
the top line is the answer. Figure A-6 gives an example of this method of binary to
decimal conversion.
Search WWH ::




Custom Search