Hexadecimal
In computer science, different number bases are used:
- is base 10, which has ten symbols (0-9)
- is base 2 , which has two symbols (0-1)
, also known as hex, is the third commonly-used number system and is base 16. It has 16 symbols - 0-9 and the capital letters A, B, C, D, E and F.
Denary | Binary | Hexadecimal |
0 | 0000 | 0 |
1 | 0001 | 1 |
2 | 0010 | 2 |
3 | 0011 | 3 |
4 | 0100 | 4 |
5 | 0101 | 5 |
6 | 0110 | 6 |
7 | 0111 | 7 |
8 | 1000 | 8 |
9 | 1001 | 9 |
10 | 1010 | A |
11 | 1011 | B |
12 | 1100 | C |
13 | 1101 | D |
14 | 1110 | E |
15 | 1111 | F |
Denary | 0 |
---|---|
Binary | 0000 |
Hexadecimal | 0 |
Denary | 1 |
---|---|
Binary | 0001 |
Hexadecimal | 1 |
Denary | 2 |
---|---|
Binary | 0010 |
Hexadecimal | 2 |
Denary | 3 |
---|---|
Binary | 0011 |
Hexadecimal | 3 |
Denary | 4 |
---|---|
Binary | 0100 |
Hexadecimal | 4 |
Denary | 5 |
---|---|
Binary | 0101 |
Hexadecimal | 5 |
Denary | 6 |
---|---|
Binary | 0110 |
Hexadecimal | 6 |
Denary | 7 |
---|---|
Binary | 0111 |
Hexadecimal | 7 |
Denary | 8 |
---|---|
Binary | 1000 |
Hexadecimal | 8 |
Denary | 9 |
---|---|
Binary | 1001 |
Hexadecimal | 9 |
Denary | 10 |
---|---|
Binary | 1010 |
Hexadecimal | A |
Denary | 11 |
---|---|
Binary | 1011 |
Hexadecimal | B |
Denary | 12 |
---|---|
Binary | 1100 |
Hexadecimal | C |
Denary | 13 |
---|---|
Binary | 1101 |
Hexadecimal | D |
Denary | 14 |
---|---|
Binary | 1110 |
Hexadecimal | E |
Denary | 15 |
---|---|
Binary | 1111 |
Hexadecimal | F |
Hexadecimal is useful because large numbers can be represented using fewer digits. For example, colour values and are often represented in hexadecimal.
Additionally, hexadecimal is easier to understand than binary. Programmers often use hexadecimal to represent binary values as they are simpler to write and check than when using binary.
Converting between binary and hexadecimal
The simplest way to convert from binary to hexadecimal, and vice versa, is to split the binary number into nibbles (four ) first, then convert each nibble to hexadecimal. A nibble can hold 16 values in its 4 bits so is useful for converting hexadecimal.
Binary to hexadecimal
- Start at the rightmost digit and break the binary number into nibbles.
- Next, convert each nibble into hexadecimal
- Put the hexadecimal digits together.
Example: 11000011 to hexadecimal
Break into nibbles: 1100 0011.
1100 = hexadecimal C and 0011 = hexadecimal 3. Remember, this is hexadecimal base 16 symbol 3, not denary symbol 3.
Result: C3
Example: 00110011 to hexadecimal
Break into nibbles: 0011 0011.
0011 = hexadecimal 3 and 0011 = hexadecimal 3
Result: 33
Hexadecimal to binary
- Split the hexadecimal number into individual digits.
- Convert each hexadecimal digit into its binary equivalent (a nibble).
- Combine the nibbles to make one binary number.
Example: hexadecimal 28 to binary
2 = binary 0010 and 8 = binary 1000
Result: 00101000
Example: hexadecimal FC to binary
F = binary 1111 and C = binary 1100
Result: 11111100
Question
What would these hexadecimal numbers be in binary?
- 11
- 2B
- AA