Number System Conversion Handout
There
are four bases to learn:
Decimal (base
10) Hexidecimal (base 16) Binary (base 2) Octal
(base 8)
0 0 0 0
1 1 1 1
2 2 10 2
3 3 11 3
4 4 100 4
5 5 101 5
6 6 110 6
7 7 111 7
8 8 1000 10
9 9 1001 11
10 A 1010 12
11 B 1011 13
12 C 1100 14
13 D 1101 15
14 E 1110 16
15 F 1111 17
16 10 10000 20
Conversions:
Recall
that each of the binary digits has a value of twice the previous digit (instead
of 10 times the previous digit, as in the decimal system). Consider the binary digit values of the
binary number 1111, which is 15 in the decimal system.
Binary digit
values:
|
128 | 64 | 32 | 16 | 8 |
4 | 2 | 1 |
------------------------------------------------------------------------
|
0 |0 | 0 | 0 | 1 |
1 | 1 | 1 |
To
convert from binary to decimal, we add up the value of each of the digits. For example:
The binary
number:
1 1 1 1
= 8+4+2+1 = 15
To
convert from decimal to binary is only slightly more involved. Let's try the number 35, for example. First, we determine the highest binary digit
value that is less than 35. The highest
is 32. So, we put down a 1 in the 6th
digit place and subtract 32 from 35 yielding 3.
1_
_ _ _ _
35
- 32 = 3
Then
we check to see if the next lowest binary digit value will fit into the
remaining value of 3. 16 is greater than 3, so we put down a zero and continue.
1
0 _ _ _ _
Eight
and four are also too large, so we put down two more zeros and continue.
1
0 0 0 _ _
The
next binary digit value, 2, is smaller than 3, so we put down a 1 and subtract
2 from 3.
1
0 0 0 1 _
3
- 2 = 1
The
last binary digit value is 1, and since we have a 1, we put down a 1 and stop.
1
0 0 0 1 1
So,
the binary number 100011 is 35 decimal.
Octal:
Each
digit in octal is worth three binary digits.
This is because the values 0-7 can be held in three bits. (zero in octal =
zero in binary, 7 octal = 111 binary).
So to convert, we simply break up a binary number into three bit
segments and write in an octal digit for each segment.
1 1 0 1 1 0 0 1 = 1 1 0 1 1 0 0 1
3 3 1
So, 11011001 = 331 octal. To convert from octal to binary, we reverse
the process.
Hex:
Converting
from hex to binary works the same way, but each digit is worth four binary
digits, intead of just 3. Convert in the same fashion as described
above for octal.
Converting
other bases:
To
perform any other conversion not covered on this sheet,
convert first to binary, then from binary to the new base.