Decimal and Hexadecimal
A gentle introduction to hexadecimal (base 16).
Decimal numbers
In our standard decimal system each digit (which can be 0,1,2,3,4,5,6,7,8,9) in a number represents a power of ten in that place:
Hexadecimal numbers
The hexidecimal (base 16) system is similar, except that each digit represents a power of 16 in that place.
Because a digit can have values greater than 9, there are additional digit symbols allowed in hex:
- A (10), B (11), C (12), D (13), E (14) and F (15)
To convert a decimal number to hex, you remove multiples of those powers of 16 as shown below.
Binary numbers
In the binary (base 2) system, each digit is a power of two, and the digits are just 0 and 1.
Because 16 is a power of 2 (2^4), every hex digit corresponds to a set of 4 binary digits ("bits"), with each digit representing a power of 2:
decimal | hex | binary |
---|---|---|
0 | 0 | 0000 |
1 | 1 | 0001 |
2 | 2 | 0010 |
3 | 3 | 0011 |
4 | 4 | 0100 |
5 | 5 | 0101 |
6 | 6 | 0110 |
7 | 7 | 0111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
10 | A | 1010 |
11 | B | 1011 |
12 | C | 1100 |
13 | D | 1101 |
14 | E | 1110 |
15 | F | 1111 |
It's easy to translate a hexadecimal number into binary because you can decompose each hex digit into its 4 bits.
The benefit of using hexadecimal instead of binary, is that hex is much shorter to write, but still lets us easily determine the value of specific bits.
Octal numbers
Another popular base in the computer world is octal – (base 8) where each digit is a power of 8, and digits are 0, 1, 2, 3, 4, 5, 6, 7.
Since 8 is also a power of 2 (2^3), each octal digit corresponds directly to 3 binary bits. So octal is more compact than binary, but less compact than either decimal or hexadecimal.
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache.