To convert (213AFE)H
to BCD, first it has to be converted to binary which gives (2177790)D
. Now each digit is converted to its BCD code which gives (0010 0001 0111 0111 0111 1001 0000)BCD
.
Another way is to convert the hex value to binary which gives (0010 0001 0011 1010 1111 1110)B
and then do BCD adjust by adding 6 to each digit greater than 9 as follows:
0010 0001 0011 1010 1111 1110
+ 0110 0110 0110
-----------------------------
0010 0001 0100 0001 0110 0100 -> 35092368D
The final result in the processes above are different. Is the second method wrong? Why?
hex-to-bcd