The Numeric Systems: Binary and Hexadecimal Conversions

 

Conversion from Binary to Hexadecimal

 

Converting a Byte From Binary to Hexadecimal

When all bits are 0, the byte also has a value of 0. When combining and mixing 0 and 1 bits, you can get binary values as varied as possible: 0101 0010 or 1101 1110 or 0111 1100. We only need to know what each combination would represent. If you divide bits by groups of four, you can use the table of numeric conversions to find out what each group represents. Consider a binary number such as 10101101. Dividing it in groups of 4-bits, we get 1010 1101. Referring to our conversion table, the low order nibble has a hexadecimal value of 8. The high order nibble has a hexadecimal value of C.

1010 1101
A D

Therefore, the binary number 10101101 has a hexadecimal representation of 0XAD.

Of course, the binary number 10101101 is equivalent to 128 + 0 + 32 + 0 + 8 + 4 + 0 + 1 = 173 in the decimal system.

Converting any Number From Binary to Hexadecimal

To convert a binary number to hexadecimal, use the table of numeric conversions. First, convert the number in groups of 4 bits. If the most left group has less than 4 bits, complete the other bits with 0 each.

Imagine you would like to convert the 100011111111011011100 binary to its hexadecimal equivalent. First create groups of 4 bits. The number becomes:

11 0001 1111 1110 1101 1100

Since the most left group has only 2 bits, you can add two 0 bits to its left to make it a group of 4. The number becomes:

0011 0001 1111 1110 1101 1100

Using the table of numeric conversions, you get:

0011 0001 1111 1110 1101 1100
  3      1      F      E      D     C
= 0x31FEDC

 

Conversion from Hexadecimal to Binary

 

Converting a Byte From Hexadecimal to Binary

The conversion of a hexadecimal number to its binary equivalent is extremely easy. The only thing you need is the table of numeric conversions. A byte is represented with two hexadecimal symbols. The right symbol represents the low nibble (the first 4 bits). The other symbol is the high nibble.

Consider a hexadecimal number such as 0X26. Referring to our table of numeric conversions, 2 has a binary representation of 0010; hexadecimal 6 is represented in binary as 0110. Therefore, the hexadecimal number 0X26 can be represented in binary as 00100110 which is easily read as 0010 0110. Remember that when a number has leading 0s, the computer ignores the 0(s). As a result, the computer would display 00100110 as 100110

Let's convert the hexadecimal 0XD5 to binary. The binary representation of D is 1101. The binary representation of 5 is 0101. Therefore, hexadecimal 0XD5 is represented in binary as 11010101 or 1101 0101

Converting any Number From Hexadecimal to Binary

To convert any hexadecimal number to binary, once again, you use the table of numeric conversion. Each hexadecimal digit will be converted to its binary equivalent.

Consider you would like to convert the hexadecimal number 0x72FA to binary. Using the table of numeric conversions:

7 = 0111
2 = 0010
F = 1111
A = 1010

Therefore, hexadecimal 0x72FA is represented in binary as 011100101111010. This can be read as 0111 0010 1111 1010. The computer would display it as 11100101111010

 

Previous Copyright �2005 Susanta K Beura.

Hosted by www.Geocities.ws

1