Beetwise

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.

  1. Write the value as hex digits: F A
  2. The hex digit F is the group 1111.
  3. The hex digit A is the group 1010.
  4. Join the groups: 11111010

Every hex digit as four bits

Every hex digit as four bits
HexBinaryDecimal
000000
100011
200102
300113
401004
501015
601106
701117
810008
910019
A101010
B101111
C110012
D110113
E111014
F111115

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 editor

Questions 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.