Converting Binary number to Hex
Posted: Fri Aug 03, 2007 9:21 am
to configure bits in registers it is fairly easy to convert between binary and hex.
eg Bx000100011
split the binary value into two sections of 4 bits
0001 and 0011
then imagine that starting from the right and working left for each block of 4 that the first bit is 1 the next bit is 2 then 4 then 8.
0001 and 0011
8421 and 8421
Addup the value of the ones.
If the value is over 9 then 10 is equal to A, 11 is equal to B ... 15 is equal to F
then you have the hex value. 0x 1 3 ... 0x13
A few other examples
Bx01010101
= 0101 0101
= 5 5
=0x55
Bx11101011
= 1110 1011
= 14 11
= E B
= 0xEB
eg Bx000100011
split the binary value into two sections of 4 bits
0001 and 0011
then imagine that starting from the right and working left for each block of 4 that the first bit is 1 the next bit is 2 then 4 then 8.
0001 and 0011
8421 and 8421
Addup the value of the ones.
If the value is over 9 then 10 is equal to A, 11 is equal to B ... 15 is equal to F
then you have the hex value. 0x 1 3 ... 0x13
A few other examples
Bx01010101
= 0101 0101
= 5 5
=0x55
Bx11101011
= 1110 1011
= 14 11
= E B
= 0xEB