Converting Between Representations |
Decimal | Hexadecimal | Binary | Octal |
---|---|---|---|
0 | 00 | 0000 0000 | 0 |
1 | 01 | 0000 0001 | 1 |
2 | 02 | 0000 0010 | 2 |
3 | 03 | 0000 0011 | 3 |
4 | 04 | 0000 0100 | 4 |
5 | 05 | 0000 0101 | 5 |
6 | 06 | 0000 0110 | 6 |
7 | 07 | 0000 0111 | 7 |
8 | 08 | 0000 1000 | 10 |
9 | 09 | 0000 1001 | 11 |
10 | 0A | 0000 1010 | 12 |
11 | 0B | 0000 1011 | 13 |
12 | 0C | 0000 1100 | 14 |
13 | 0D | 0000 1101 | 15 |
14 | 0E | 0000 1110 | 16 |
15 | 0F | 0000 1111 | 17 |
16 | 10 | 0001 0000 | 20 |
17 | 11 | 0001 0001 | 21 |
18 | 12 | 0001 0010 | 22 |
. . . | . . . | . . . | . . . |
255 | FF | 1111 1111 | 377 |
A binary, a hexadecimal or an octal number can be expressed as the sum of the successive powers of the base (either 2, 16 or 8), with the coefficients being the digits.
For example,
Decimal | 1111(base 10) = | 1 1000 (103) |
1 100 (102) |
1 10 (101) |
1 1 (100) |
= (1*1000) + (1*100) + (1*10) + (1*1) = 1111(base 10) |
Hexadecimal | 1111(base 16) = | 1 4096 (163) |
1 256 (162) |
1 16 (161) |
1 1 (160) |
= (1*4096) + (1*512) + (1*16) + (1*1) = 4369(base 10) |
Binary | 1111(base 2) = | 1 8 (23) |
1 4 (22) |
1 2 (21) |
1 1 (20) |
= (1*8) + (1*4) + (1*2) + (1*1) = 15(base 10) |
Octal | 1111(base 8) = | 1 512 (83) |
1 64 (82) |
1 8 (81) |
1 1 (80) |
= (1*512) + (1*64) + (1*8) + (1*1) = 585(base 10) |
To convert a decimal number into a binary number, divide it by 2 repeatedly and note the remainders. The remainders are the bits of the binary number.
For example,
13(base 10) = 1101(base 2) | 13 ÷ 2 = 6 | remainder | 1 | LSB | ||||
6 ÷ 2 = 3 | remainder | 0 | ||||||
3 ÷ 2 = 1 | remainder | 1 | ||||||
1 ÷ 2 = 0 | remainder | 1 | MSB | |||||
NOTE: that the last remainder is the MSB, and the first remainder is the LSB. |
There are two different ways to convert a decimal number into a hexadecimal number.
1. The first method is similar to converting a decimal to a binary and involves dividing the number by 16 and noting the remainders.
For example,
4620(base 10) = 120C(base 16) | 4620 ÷ 16 = 288 | remainder | 12 = C | LSB | ||||
288 ÷ 16 = 18 | remainder | 0 | ||||||
18 ÷ 16 = 1 | remainder | 2 | ||||||
1 ÷ 16 = 0 | remainder | 1 | MSB |
2. The second method involves converting the decimal into a binary, then convert the binary into a hexadecimal number by grouping the digits into 4-bit groups. Beginning with the LSB, write the hexadecimal equivalent of each group.
For example,
23(base 10) = 17(base 16) | ||||||||
23(base 10) = 0001 0111(base 2) | 23 ÷ 2 = 11 | remainder | 1 | LSB | ||||
11 ÷ 2 = 5 | remainder | 1 | ||||||
5 ÷ 2 = 2 | remainder | 1 | ||||||
2 ÷ 2 = 1 | remainder | 0 | ||||||
1 ÷ 2 = 0 | remainder | 1 | MSB |
0001 0111(base 2) = 17(base 16) | 0001 |
0111 |
|
1 | 7 |
To convert an octal number into a binary number, divide it by 8 repeatedly and note the remainders. The remainders are the bits of the binary number.
For example,
1701(base 10) = 3245(base 8) | 1701 ÷ 8 = 212 | remainder | 5 | LSB | ||||
212 ÷ 8 = 26 | remainder | 4 | ||||||
26 ÷ 8 = 3 | remainder | 2 | ||||||
3 ÷ 8 = 0 | remainder | 3 | MSB | |||||
NOTE: that the last remainder is the MSB, and the first remainder is the LSB. |
To convert a binary number into its hexadecimal form, start by grouping the digits into 4-bit groups. Beginning with the LSB (all the way to the right of the number), write the hexadecimal equivalent of each group.
For example,
1001111101100101(base 2) = 9F65(base 16) | 1001 |
1111 |
0110 |
0101 |
(base 2) | |
9 | F | 6 | 5 | (base 16) | ||
MSB | LSB |
To convert a hexadecimal into a binary number, just reverse the above process; beginning with the LSB, convert each digit into a 4-bit binary number.
To convert a binary number into its octal form, start by grouping the digits into 3-bit groups. Beginning with the LSB (all the way to the right of the number), write the octal equivalent of each group.
For example,
10110111011(base 2) = 4672(base 8) | 010 |
110 |
111 |
011 |
(base 2) | |
2 | 6 | 7 | 3 | (base 8) | ||
MSB | LSB |
To convert an octal into a binary number, just reverse the above process; beginning with the LSB, convert each digit into a 3-bit binary number.
This page is for INFORMATIONAL PURPOSES ONLY.
Page author: Dawn Rorvik (rorvikd@evergreen.edu)