FLXCode Binary to Hex Converter

FLXCode apps

Appearance

Binary to Hex Converter

Paste a binary number and get hex. Below the tool, the nibble table shows the digit each group of four bits becomes.

Example

D6A

1101 0110 1010 in base 2 (binary) is D6A in base 16 (hexadecimal) (3434 in decimal).

Steps

  1. Each digit is worth its value times a power of 2: 110101101010 = 1 × 2¹¹ + 1 × 2¹⁰ + 0 × 2⁹ + 1 × 2⁸ + 0 × 2⁷ + 1 × 2⁶ + 1 × 2⁵ + 0 × 2⁴ + 1 × 2³ + 0 × 2² + 1 × 2¹ + 0 × 2⁰ = 3434.
  2. Divide by 16 again and again. The remainders, read from the last to the first, are the digits: 3434 ÷ 16 = 214 remainder 10 (A); 214 ÷ 16 = 13 remainder 6; 13 ÷ 16 = 0 remainder 13 (D).

The same number in the common bases

BaseValue
base 2 (binary)1101 0110 1010
base 8 (octal)6552
base 10 (decimal)3434
base 16 (hexadecimal)D6A

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.

Problem or idea? Email us

Worked examples

BinaryHexNote
1111FFour ones are one F
1010 0101A5A byte becomes two hex digits
1101 0110 1010D6ATwelve bits, three digits
1015Short groups are padded on the left: 0101
1111 1111 1111 1111FFFFThe largest 16-bit value
1000 0000 0000 0000 0000 0000 0000 000080000000Bit 31 alone, the sign bit of a 32-bit word
1100119Five bits: 1 1001 becomes 0001 1001

The by-hand method

  1. Start at the right end and mark off groups of four bits.
  2. Add zeros to the left of the last group if it has fewer than four bits.
  3. Look each group up in the table below.
  4. Write the digits in the same order.

1011 0110 0011: 1011, 0110, 0011 is B, 6, 3, so the hex number is B63.

The sixteen groups

4 bitsHexDecimal
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
1010A10
1011B11
1100C12
1101D13
1110E14
1111F15

Each bit in a group is worth 8, 4, 2 or 1 from left to right. Add the weights of the ones: 1011 is 8 + 2 + 1 = 11, which is B.

Why programmers use it

A long string of bits is hard to read and easy to miscopy. Hex writes the same bits in a quarter of the characters, and every digit maps back to four bits with no arithmetic. Registers, bit masks and memory dumps are usually shown this way. To go the other way use hex to binary. For a decimal result, or for a base such as 8 or 36, open the number base converter.

If you want to do arithmetic on the number, not just rewrite it, the programmer calculator shows hex and binary side by side, with a bit grid you can click.

Numbers this uses

  • Digits 0 and 1. Spaces, underscores and a 0b prefix are ignored.
  • Up to 1,000 characters, exact (BigInt). Fractions are allowed.
  • Groups of four bits are counted from the binary point outward.

Nothing you type is uploaded. We count events without cookies (details).

FAQ

How do I convert binary to hex?

Split the bits into groups of four, starting from the right. Pad the leftmost group with zeros if it is short. Replace each group with its hex digit from the table above. 1011 0110 0011 becomes B, 6, 3, so B63.

Why four bits at a time?

Sixteen is 2 to the power of 4, so one hex digit holds exactly four bits and nothing carries from one group to the next. That is why you never need to add or multiply to do this conversion. You only look up groups.

What if my binary number does not fill a whole number of groups?

Add zeros on the left. 11001 is 1 1001, so pad it to 0001 1001, which is 19 in hex. Leading zeros do not change the value, and the tool pads for you.

Can I type spaces, underscores or a 0b prefix?

Yes. 1111 0000, 1111_0000 and 0b11110000 all give F0. Anything other than 0 and 1 is refused with a message that names the digit.

How do I read a binary number as hex when it is a signed value?

Convert the bit pattern exactly as it is. 1111 1111 is FF whether you call it 255 or -1. The sign only matters when you turn it into a decimal number. The programmer calculator lets you switch between the two readings.

How long a binary number can I convert?

Up to 1,000 characters, converted exactly with BigInt. A 64-bit pattern, 128 bits or a whole hash converts with no rounding.

Does it do binary fractions?

Yes. Put a point in: 1010.1 is A.8 in hex. The places after the point are halves, quarters and so on, and every four of them make one hex digit after the point.

Is my number sent or stored?

No. The conversion runs in your browser. What you type is not put in the address bar, not stored and not counted. We only count the base you converted to.

More from FLXCode

Share Binary to Hex Converter