Text and numbers can be encoded in a computer as patterns of binary digits. Hexadecimal is a shortcut for representing binary. ASCII and Unicode are important character sets that are used as standard.

To convert denary numbers to hex, you need to remember the equivalent binary numbers for the first 16 hex digits.

To represent the denary number **12** in a computer system, you could use binary **1100** or hex value **C**.

To convert a 4-bit binary number to hex:

Binary | Denary | Hex |
---|---|---|

1100 | (1x8) + (1x4) + (0x2) + (0x1) = 12 | C |

A byte is made of eight binary digits. To convert an 8-bit binary number to hex, separate it into two nibbles or two half-bytes.

Binary | Denary | Hex |
---|---|---|

1011 1001 | 11 and 9 | B9 |

There are two methods of converting hex to denary:

Separate the hex digits to find each equivalent in binary, and then piece them back together.

- Separate the hex digits into
**2**and**D**and find the equivalent binary numbers (**2 = 0010; D = 1101**). - Piece them together to get
**00101101**(0x128 + 0x64 + 1x32 + 0x16 + 1x8 + 1x4 + 0x2 + 1x1 =**45 in denary**).

Another method is to create base 16 place-value columns, and add the hex value to the appropriate columns. You would then need to work out what the hex digits represent in denary, and multiply this figure with the place-value. Finally, add all the values together.

The base 16 columns would be (16^{1}=16), (16^{2}=256), (16^{3}=4096), etc.

- Add the hex value to the appropriate base 16 place-value column:
**2**in the 16 column;**D**in the 1 column. - Work out what the hex digits represent in denary:
**2**= 2 in denary;**D**= 13 in denary. - Multiply this figure with the place value: 2 x 16 = 32; 13 x 1 = 13.
- Add the values together: 32 + 13 =
**45 in denary**.