Convert hex to binary
To convert a hex value into binary, take each hex digit in turn.
Replace the digit with its four bits.
Join the groups in the same order.
Try hex to binary conversion in the bit editor
The value 0xFA as bits. Edit the expression or select a bit to flip it.
7
6
5
4
3
2
1
0
0b11111010
binary · 8 bits
- hex
- 0xFA
Hex to binary conversion step by step
Convert 0xFA into binary: The steps follow the value above.
- Write the value as hex digits: F A
- The hex digit F is the group 1111.
- The hex digit A is the group 1010.
- Join the groups: 11111010
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 to binary conversion is used
A data sheet gives a register reset value in hex.
A binary form shows which bits the reset value sets, which the hex form hides.
A conversion into binary is the first step. Then you write a mask for one field.
A configuration value in a header file is also in hex, so the same conversion applies.
Hex to binary conversion: points to note
- Write all four bits for every digit, with the zeros at the left. The digit 2 is 0010, not 10.
- Do not change the order of the digits. The first hex digit gives the highest four bits.
- The result has four bits for each hex digit. Two digits give one byte, and eight digits give a 32-bit value.
- A hex value with an odd number of digits does not fill a whole number of bytes. Add a zero at the left first.
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 to binary conversion
- What is 0xFA in binary?
- The value 0xFA is 11111010. The digit F gives 1111 and the digit A gives 1010.
- Why must I keep the zeros at the left?
- Each digit holds exactly four bit positions. A zero that you omit moves all the later bits to a lower position and changes the value.
- What is 0xFF in binary?
- The value 0xFF is 11111111. All eight bits have the value 1, so 0xFF is the mask for one full byte.
- How many bits does a hex value have?
- Multiply the number of digits by four. A value of four digits, such as 0x12C4, has 16 bits.