Why hex suits binary values
One hex digit shows exactly four bits.
Two hex digits show exactly one byte.
Hex is shorter than binary, and each digit maps to a fixed group of bits. A decimal digit does not.
Try hex notation in the bit editor
The value 0xFA, which is 11111010. Edit the expression or select a bit to flip it.
7
6
5
4
3
2
1
0
0xFA
hex · 8 bits
- value
- 250
Hex notation step by step
Convert 11111010 into hex:
- Split the bits into groups of four, from the right: 1111 and 1010.
- Convert the first group: 1111 is F.
- Convert the second group: 1010 is A.
- The result is 0xFA.
Every hex digit as four bits
| Hex | Binary | Decimal |
|---|---|---|
| 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 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
Where hex notation is used
A data sheet gives register addresses and reset values in hex.
A hex value shows the bit pattern directly, so a change of one digit changes exactly four bits.
A decimal value hides the bit pattern, which makes a mask hard to read.
Hex notation: points to note
- A decimal digit does not map to a group of bits. The value 10 in decimal covers parts of two bit groups.
- The prefix 0x marks a hex value. The prefix 0b marks a binary value.
- A hex value with an odd number of digits is not a whole number of bytes. Add a zero at the left for clarity.
The full bit editor
The full editor holds many values, evaluates expressions across them, and reads live values from a serial port.
Open this value in the full editorQuestions about hex notation
- How many bits does one hex digit hold?
- One hex digit holds exactly four bits, which gives the values 0 to 15.
- Why is 0xFF used so often?
- The value 0xFF is one full byte with all bits set. The value is the mask for one byte.
- Is hex the same as binary?
- Hex is a shorter form of the same bits. The value does not change, only the display.