In: Computer Science
Number conversion between hexadecimal and binary. Show the working steps. a) Convert the hexadecimal number E4D2 into binary. b) Convert the binary number 1100010111110011 into hexadecimal
a)hexadecimal to binary
E4D2
Each digit in hexadecimal has a corresponding 4 digit binary For this we can use a table
Hexadecimal. binary
0. 0000
1. 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C. 1100
D 1101
E 1110
F. 1111
We can start conversion. In our question E4D2,
i) Take the rightmost digit 2 then give value from the table that is 0010.
ii)Second digit is D, give 1101 value
iii)Third digit is 4,give 0100
iv)Last digit is E, write it as 1110.
So the convertes binary number we can start from the E value.
That is. (E4D2)16 becomes (1110 0100 1101 0010)2
b) Binary to Hexadecimal
It is the reverse process what we do above.
Step 1) make a group of 4 bits from the rightmost part.
Step2) Give each 4 bit to group to corresponding hexavalue from the above table.
1100 0101 1111 0011
C 5 F 3
So the converted hexa value is
(1100010111110011)2 becomes(C5F3)16
Note: IT is not necessary to study the table we can write it using 8421 code.
That is 8 4 2 1
1 1 1 1
If we want to get binary of 5, then using 8421 code here 4+1=5. So the position of 4 and 1 Should be 1. Give remaining position to 0.That is
8 4 2 1
0 1 0 1.
If we want to convert D to binary, first look D's corresponding decimal value is 13. Using 8421 code, 8+4+1 is 13. So give these position to 1 and others becomes 0.
8 4 2 1
1 1 0 1