Although the BCD system increases the flexibility and ease of programming numeric data, it does require more computer space to record each number. The hexadecimal (hex) system, using base 16, incorporates the convenience of the BCD system with the full stor-
age capabilities. It is base 16 that uses the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Each hex place value is expressed in binary by a group of four bits, as shown in Table 2.4.
Decimal Hexadecimal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0110
6 6 0111
7 7 1000
8 8 1001
9 9 1010
10 A 1011
11 B 1100
12 C 1101
13 D 1110
14 E 1111
15 F 1111
For example, consider a string (0010 1111 0001 1110 1100). This can be converted into hexadecimal system as follows.
0010 1111 0001 1110 1100
2 F 1 E C =(2F1EC)
We take few examples for demonstrating the conversion procedure from one number system to another system.
Example 1: Convert the following numbers into decimal system:
(i) 101011010 (Binary)
(ii) 765 (Octal)
(iii) 125F (Hexadecimal)
Solution:
(i) 10101010 (binary)
= 1 x 2
7
+ 0 x 2
6
+ 1 x 2
5
+ 0 x 2
4
+ 1 x 2
3
+ 0 x 2
2
+
1 x 2
1
+ 0 x 2
0
= 1 x 128 + 1 x 32 + 1 x 8 + 1 x 2
= 128 + 32 + 8 + 2 = 170
Hence 10101010 (binary) = 170 (decimal)
(ii) 765 (octal)
= 7 x 8
2
+ 6 x 8
1
+ 5 x 8
0
= 7 x 64 + 6 x 8 + 5 x 1
= 448 + 48 + 5 = 501
Hence 765 (octal) = 501 (decimal)
(iii) 125F (Hexadecimal)
= 1 x 16
3
+ 2 x 16
2
+ 5 x 16
1
+ 15 x 16
0
= 1 x 4096 + 2 x 256 + 5 x 16 + 15 x 1
= 4096 + 512 + 80 + 15
= 4703
Hence 125F (Hexadecimal) = 4703 (decimal).
The number (2F1EC)
16
can be converted into decimal system as
follows:
Positional 16
4
16
3
16
2
16
1
16
0
Value 2 F 1 E C
12 x 1 = 12
14 x 16 = 224
1 x 256 = 256
15 x 4096 = 61,440
2 x 65536 = 1,31,072
= 1,93,004
Thus (0010 1111 0001 1110 1100)
2
= (2F1EC)
16
= (193004)
10
Example 2: Write the BCD equivalent of the following binary numbers:
(i) 110101
(ii) 10111
(iii) 1010110
Solution:
(i) 110101 = 1 x 2
5
+ 1 x 2
4
+ 0 x 2
3
+ 1 x 2
2
+ 0 x 2
1
+ 1 x 2
0
= 32 + 16 + 4 + 1 = 53
= 0101 0011 (in BCD)
(ii) 10111 = 1 x 2
4
+ 0 x 2
3
+ 1 x 2
2
+ 1 x 2
1
+ 1 x 2
0
= 16 + 4 + 2 + 1 = 23
= 0010 0011 (in BCD)
(iii) 1010110 = 1 x 2
6
+ 0 x 2
5
+ 1 x 2
4
+ 0 x 2
3
+ 1 x 2
2
+
1 x 2
1
+ 0 x 2
0
= 64 + 16 + 4 + 2 = 86
= 1000 0110 (in BCD)
Example 3: Convert the following from one number system to another number system:
(i) (123) decimal = ( ) binary
(ii) (1011010) binary = ( ) decimal
(iii) (4567) octal = ( ) decimal
(iv) (BABA) hexadecimal = ( ) decimal
(v) (1357) octal = ( ) binary
Solution :
(i) (123) decimal = ( ) binary
2 123 Remainder
2 61 1
2 30 1
2 15 0
2 7 1
2 3 1
2 1 1
0 1
Hence, (123) decimal = (1111011) binary
(ii) (1011010) binary = ( ) decimal
(1011010)
2
= 1x2
6
+0x2
5
+1x2
4
+1x2
3
+0x2
2
+1x2
1
+0x2
0
= 64 + 16 + 8 + 2
= 90
(1011010) binary = (90) decimal
(iii) (4567) octal = ( ) decimal
(4567)
8
= 4x8
3
+5x8
2
+6x8
1
+7x8
0
= 4x512+5x64+6x8+7
= 2048 + 320 + 48 + 7
= 2423
Hence, (4567) octal = (2423) decimal
(iv) (BABA) hexadecimal = ( ) decimal
(BABA)
16
= 11 x 16
3
+ 10 x 16
2
+ 11 x 16
1
+
10 x 16
0
= 11 x 4096 + 10 x 256 + 11 x
16 + 10
= 45056 + 2560 + 176 + 10
= 47802
Hence, (BABA) hexadecimal = (47802) decimal
(v) (1357) octal = ( ) hexadecimal
To convert the given number from octal to hexadecimal, let us first represent each digit by a group of three binary bits. Thereafter, we combine these bits in groups of four, starting from right to left and adding significant zeros if required.
(1357) octal = 001 011 101 111
= 0010 1110 1111
= (2 E F)
(1357) octal = (2EF) hexadecimal