Developer Bases

Binary to hex

Binary value
Hexadecimal AF
Group into fours from the right
The same number elsewhere
Decimal 175
Binary 10101111
Binary, grouped 1010 1111
Octal 257
Bits needed 8
Note
Pad on the left, never the right
DecimalBinaryOctalHex
0000
1111
81000108
10101012A
15111117F
16100002010
64100000010040
100110010014464
25511111111377FF
256100000000400100
1024100000000002000400
655351111111111111111177777FFFF
Advertisement
320 × 100

Group the binary digits into fours starting from the right, padding the left with zeros, then read each group as one hex digit. 10101111 becomes 1010 1111, which is AF.

How to convert binary to hex

1 Enter the bits — spaces between groups are accepted and ignored.
2 Read the hexadecimal result.
3 Pad from the left, never the right, or every digit shifts.
4 Check the decimal value as a sanity check.

Padding direction is the mistake worth avoiding. Binary places carry value by position from the right, so a group of fewer than four bits must be padded on the left with zeros. Padding on the right multiplies the number — 101 padded to 1010 is ten rather than five. The grouped output above always pads correctly, which is why it is worth reading rather than doing it by eye on a long string.

Questions

F, which is 15 in decimal.

Advertisement
300 × 250
Was this tool any good?
INTERNAL SIGNAL ONLY · WE USE IT TO FIND TOOLS WORTH REBUILDING