Decimal
Binary
Octal
Hexadecimal
Binary Coded Decimal (BCD)
• At the end of this chapter, students should
be able to:-
– Differentiate between decimal, binary, octal,
hexadecimal and BCD.
– Convert number between bases.
10/9/2012 RA/Sept2013-Jan2014 2
10/9/2012 RA/Sept2012-Jan2013 3
Type Base Numbers/Symbols
Decimal 10 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Binary 2 0, 1
Octal 8 0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal 16 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
10/9/2012 RA/Sept2012-Jan2013 4
Binary Octal Decimal Hexadecimal
0 0 0 0
1 1 1 1
10 2 2 2
11 3 3 3
100 4 4 4
101 5 5 5
110 6 6 6
111 7 7 7
1000 10 8 8
1001 11 9 9
1010 12 10 A
1011 13 11 B
1100 14 12 C
1101 15 13 D
1110 16 14 E
10/9/2012 1111 17RA/Sept2012-Jan201315 F 5
10/9/2012 RA/Sept2012-Jan2013 6
Decimal - Binary
Technique:
– Divide the decimal number by 2, keep track of the remainder.
– First remainder is the Least Significant Bit (LSB).
Eg. 8710 = _________ 2
2 87 43 remainder 1 LSB (Least Significant Bit)(right-most bit)
2 43 21 remainder 1
2 21 10 remainder 1
2 10 5 remainder 0
2 5 2 remainder 1
2 2 1 remainder 0
2 1 0 remainder 1 MSB (Most Significant Bit)(left-most bit)
Therefore, 8710 = 10101112
Binary – Decimal
Technique:
– Multiply each hexadecimal number by 2n, where n is the weight of the bit.
– The weight is the position of the bit, starting from 0 on the right. (LSB)
– Then, sum the results. MSB LSB Description
Eg. 10101112 = _________ 10
2
6 5
2 4
23
22
2
1
20
2 Bit Weights
1 0 1 0 1 1 1 Binary Number
= 1*26 + 1*24 + 1*22 + 1*21 + 1*20
= 64 + 16 + 4 + 2 + 1
= 8710
10/9/2012 RA/Sept2012-Jan2013 7
Decimal - Octal
Technique:
– Divide the decimal number by 8, keep track of the remainder.
– First remainder is the Least Significant bit (LSB).
Eg. 26610 = _________ 8
8 266 33 remainder 2 LSB (Least Significant Bit)(right-most digit)
8 33 4 remainder 1
8 4 0 remainder 4 MSB (Most Significant Bit)(left-most digit)
Therefore, 26610 = 4128
Octal – Decimal
Technique:
– Multiply each octal number by 8n, where n is the weight of the digit.
– The weight is the position of the digit, starting from 0 on the right. (LSD)
– Then, sum the results.
MSD LS Description
Eg. 4128 = _________ 10 D
82 81 80 Bit Weights
4 1 2 Octal Number
4128 = (4 x 82 ) + (1 x 81) + (2 x 80)
= 256 + 8 + 2
= 26610
10/9/2012 RA/Sept2012-Jan2013 8
Decimal - Hexadecimal
Technique:
– Divide the decimal number by 16, keep track of the remainder.
– First remainder is the Least Significant Digit (LSD).
Eg. 42310 = _________ 16
16 423 26 remainder 7 LSD (Least Significant Digit)(right-most digit)
16 26 1 remainder 10
16 0 0 remainder 1 MSD (Most Significant Digit)(left-most digit)
Therefore, 42310 = 1A716
Hexadecimal – Decimal
Technique:
– Multiply each hexadecimal number by 16n, where n is the weight of the digit.
– The weight is the position of the digit, starting from 0 on the right. (LSD)
– Then, sum the results.
MSD LS Description
Eg. 1A716 = _________ 10
D
162 161 160 Hex Digit Weights
1 A 7 Hex Number
= (1 x 162 ) + (10 x 161) + (7 x 160)
= 256 + 160 + 7
= 42310.
10/9/2012 RA/Sept2012-Jan2013 9
Decimal - BCD
Technique:
Replace each decimal digit (0 – 9) with a 4-bit BCD code. Decimal BCD
Eg. 87410 = _________ BCD 0 0000
MSD LSD Description
1 0001
8 7 4 Decimal Number
1000 0111 0100 BCD Code 2 0010
3 0011
Therefore, 87410 = 100001110100BCD
4 0100
BCD – Decimal 5 0101
Technique: 6 0110
Replace each 4 bits BCD digit with a decimal number. 7 0111
Eg. 0001100101111000BCD = _________ 10 8 1000
MSD LSD Description 9 1001
0001 1001 0111 1000 BCD Code
1 9 7 8 Decimal Number
10/9/2012 RA/Sept2012-Jan2013 10
Therefore, 0001100101111000 = 1978
Binary - Octal
Technique:
- Group bits in threes, starting from right (LSB).
- Then, convert to octal.
MSD LS Description
D
Eg. 110101102 = _________ 8 011 010 110 Binary number
3 2 6 Octal number
Therefore, 110101102 = 3268
Octal – Binary
Technique:
- Replace each octal digit with 3-bit binary number.
MSD LS Description
Eg. 4728 = _________ 2 D
4 7 2 Octal number
100 111 010 Binary number
Therefore, 4728 = 1001110102
10/9/2012 RA/Sept2012-Jan2013 11
Binary - Hexadecimal
Technique:
- Group bits in fours, starting from right (LSB).
- Then, convert to hexadecimal.
MSD LSD Description
Eg. 101111110101102 = _________ 16
0010 1111 1101 0110 Binary Number
2 F D 6 Hex Number
Therefore, 101111110101102 = 2FD616
Hexadecimal – Binary
Technique:
- Replace each octal digit with 4-bit binary number.
MSD LSD Description
Eg. 1A716 = _________ 2 1 A 7 Hex Number
0001 1010 0110 Binary Number
Therefore, 1A716 = 0001101001112
10/9/2012 RA/Sept2012-Jan2013 12
Octal - Hexadecimal
Technique:
- Use binary as an intermediary. Description
1 7 4 . 3 6 Octal number
Eg. 174.368 = _________ 16
001 111 100 . 011 110 Binary number
7 C . 7 8 Hexadecimal number
Therefore, 174.368 = 7C.7816
Hexadecimal - Octal
Technique:
- Use binary as an intermediary.
Description
Eg. 7C.7816 = _________ 8
7 C . 7 8 Hexadecimal number
0111 110 . 0111 1000 Binary number
0
3 6 0 Octal number
.
1 7 4
Therefore, 7C.7816 = 174.368
10/9/2012 RA/Sept2012-Jan2013 13
Decimal - Binary
Eg. Convert 23.37510 to base 2.
Technique:
1. Start by converting the integer portion:
10/9/2012 RA/Sept2012-Jan2013 14
2. Then, convert the fraction:
(Take 0)
(Take 1)
(Take 1)
Putting it all together, 23.37510 = 10111.0112
10/9/2012 RA/Sept2012-Jan2013 15
Binary - Decimal
Technique:
– Multiply each binary number by 2-n, where -n is the weight of the bit for fraction
starting from left to right. .
– Then, sum the results.
Eg. 1010.012 = _________ 10
1010.012 = 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 0 x 2-1 + 1 x 2-2
= 10 + 0.25
= 10.25 10
Therefore, 1010.012 = 10.2510
10/9/2012 RA/Sept2012-Jan2013 16
Octal – Decimal
Technique:
– Multiply each octal number by 8-n, where -n is the weight of the bit for fraction
starting from left to right. .
– Then, sum the results.
Eg. 46.38 = _________ 10
46.38 = 4 x 81 + 6 x 80 + 3 x 8-1
= 38 + 0.375
= 38.375 10
Therefore, 46.38 = 38.37510
10/9/2012 RA/Sept2012-Jan2013 17
Hexadecimal - Decimal
Technique:
– Multiply each hexadecimal number by 16 -n, where -n is the weight of the bit for
fraction starting from left to right. .
– Then, sum the results.
Eg. A7.0F16 = _________ 10
A7.0F16 = 10 x 161 + 7 x 160 + 0 x 16-1 + 15 x 16-2
= 167 + 0.059
= 167.059 10
Therefore, A7.0F16 = 167.05910
10/9/2012 RA/Sept2012-Jan2013 18
BCD – Binary, Octal, Hexadecimal
Technique:
– First, convert the BCD number to decimal.
– Then, convert the decimal number to the indicated base .
Eg. 01011000BCD = _________ 8
01011000BCD = 5810 = 728
Therefore, 01011000BCD = 728
Binary, Octal, Hexadecimal - BCD
Technique:
– First, convert the indicated base to decimal.
– Then, convert the decimal number to BCD.
Eg. E216 = _________ BCD
E216 = 22610 = 001000100110BCD
Therefore, E2 16 = 001000100110BCD
10/9/2012 RA/Sept2012-Jan2013 19
1. Convert the following number to the indicated base/code.
No. Binary Octal Decimal Hexadecimal BCD
1. 10101112
2. BACA16
3. 10010011BCD
4. 3248
5. 69410
2. Convert the following number to the indicated base/code.
a) 11101.112 to decimal.
b) FED.4716 to octal.
c) 01101001BCD to binary.
d) 7548 to BCD.
e) 152.2510 to hexadecimal.
10/9/2012 RA/Sept2012-Jan2013 20