Convert binary to hex
To convert a binary value into hex, split the bits into groups of four.
Start at the right side.
Convert each group into one hex digit.
Try it
The bits 11111010, which give 0xFA. Select a bit to change it. Change the bit width or the signed mode to see the effect.
Name or expression
ID0
ASCII
·
Binary
0b
0b11111010
Hex
0x
0xFA
Decimal
250
Shift
Name or expression
ID0
Binary
0b
Hex
0x
Decimal
ASCII
·
Shift
Sign
Bits
Endian
7
6
5
4
3
2
1
0
Worked example
Convert 11111010 into hex:
- Split the bits from the right: 1111 and 1010.
- Convert 1111. The value is 15, which is the digit F.
- Convert 1010. The value is 10, which is the digit A.
- The result is 0xFA.
Where this is used
A hex form is shorter than a binary form and holds the same bits.
A group of four bits is often one field in a hardware register.
Points to note
- Always start the groups at the right side. A group at the left side gives a wrong result.
- Add zeros at the left if the last group has fewer than four bits.
- The number of hex digits is the number of bits divided by four. A 32-bit value gives eight digits.
The full tool
The full editor holds many values at the same time. It also evaluates expressions across them, and it reads live values from a serial port.
Open the full editorQuestions
- What is 11111010 in hex?
- The value is 0xFA. The group 1111 is F and the group 1010 is A.
- Why groups of four?
- Four bits hold the values 0 to 15, which is exactly the range of one hex digit.
- What if the bits do not divide by four?
- Add zeros to the left group. The zeros do not change the value.