Java Reference
In-Depth Information
Consider the binary number 1101100010101. To find the equivalent octal number, starting
from right to left, we consider three digits at a time and write their octal representation. Note
that the binary number 1101100010101 has only 13 digits. So when we consider three digits
atatime,attheend,wewillbeleftwithonlyonedigit.Inthiscase,wejustaddtwo0stothe
left of the binary number; the equivalent binary number is 001101100010101. Thus:
1101100010101
2
¼ 001101100010101
2
¼ 001 101 100 010 101
¼
15425
8
because 001
2
¼ 1
8
, 101
2
¼5
8
, 100
2
¼ 4
8
, 010
2
¼ 2
8
, and
101
2
¼ 5
8
.
Thus, 1101100010101
2
¼
15425
8
.
To convert an octal number into an equivalent binary number, using Table D-1, write
the binary representation of each octal digit in the number. For example:
3761
8
¼ 011 111 110 001
2
¼ 011111110001
2
¼ 11111110001
2
.
Thus, 3761
8
¼
11111110001
2
.
Next, we discuss how to convert a binary number into an equivalent hexadecimal
number and vice versa. The method to do so is similar to converting a number from
binary to octal and vice versa, except that here we work with four binary digits. Table D-
2 gives the binary representation of the first 16 hexadecimal numbers.
TABLE D-2
Binary Representation of First 16 Hexadecimal Numbers
Binary
Hexadecimal
Binary
Hexadecimal
0000
0
1000
8
0001
1
1001
9
0010
2
1010
A
0011
3
1011
B
0100
4
1100
C
0101
5
1101
D
0110
6
1110
E
0111
7
1111
F
Search WWH ::
Custom Search