Skip to content
OverCalculator
  1. Home
  2. Math & Scientific
  3. Binary to Hexadecimal Calculator
Math & Scientific

Binary to Hexadecimal Calculator

Convert binary numbers to hexadecimal and hexadecimal digits to binary while understanding four-bit grouping, base 2, base 16, padding, and width limits.

Published

Converted value
Hexadecimal representation
A
Binary input
1010

Binary digits are padded to groups of four before conversion.

Conversion type
Binary input cannot exceed 16 bits.

Results update as you type.

Binary to Hexadecimal Calculator

A binary to hexadecimal calculator converts strings of base-2 bits into compact base-16 notation, and it can expand selected hexadecimal digits back into binary. This is an encoding task, not just a classroom arithmetic trick. Hexadecimal is common in memory addresses, machine code, bit masks, Unicode references, color channels, and debugging output because it represents four bits per digit without losing the underlying binary pattern.

Binary and hexadecimal as place-value systems

Binary uses two symbols, 0 and 1. Each place is a power of 2, so the rightmost bit is the ones place, the next is twos, then fours, eights, and so on. Hexadecimal uses sixteen symbols: 0 through 9 followed by A through F. Its places are powers of 16, so the rightmost place is ones, then sixteens, then two hundred fifty-sixes.

The reason programmers like hex is the exact relationship between the bases. Four binary digits have 16 possible patterns, from 0000 through 1111. One hexadecimal digit also has 16 possible symbols. Therefore each nibble, a four-bit group, can be written as exactly one hex digit. This preserves bit boundaries in a way decimal usually does not.

For example, the byte 11010110 can be split into 1101 and 0110. The first group is D and the second group is 6, so the hex form is D6. You can reverse the process with no ambiguity: D expands to 1101 and 6 expands to 0110.

Conversion rules and math

For a four-bit group with bits b3b_3, b2b_2, b1b_1, and b0b_0, the digit value is

digit value=8×b3+4×b2+2×b1+b0\text{digit value} = 8 \times b_3 + 4 \times b_2 + 2 \times b_1 + b_0

where each bit is either 0 or 1. The values 0 through 9 use the same symbols in decimal and hexadecimal. Values 10 through 15 use A, B, C, D, E, and F.

If the binary string length is not a multiple of four, pad with leading zeros before grouping:

padded length=4×bit length4\text{padded length} = 4 \times \left\lceil \frac{\text{bit length}}{4} \right\rceil

The padding is placed on the left because the rightmost bits represent the lowest place values and must remain aligned. Leading zeros do not change an unsigned numeric value, but they can preserve a chosen width when you are documenting bytes, registers, masks, or file formats.

For hexadecimal to binary, convert each digit independently into a four-bit group. The digit A has value 10, and

10=8+210 = 8 + 2

so A becomes 1010. The digit 5 has value 5, and

5=4+15 = 4 + 1

so 5 becomes 0101 with leading zeros to make a full four-bit group.

Examples: binary and hexadecimal conversions

The default binary input is 1010. Its length is already four bits, so no padding is needed. The digit value is

8×1+4×0+2×1+0=108 \times 1 + 4 \times 0 + 2 \times 1 + 0 = 10

Decimal 10 is represented by A in hexadecimal, so the calculator displays hexadecimal representation A. It also reports the binary input as 1010 and notes that binary digits are padded to groups of four before conversion.

For a longer binary example, enter 11010110. Group from the right:

110101101101 011011010110 \rightarrow 1101\ 0110

For 1101:

8×1+4×1+2×0+1=138 \times 1 + 4 \times 1 + 2 \times 0 + 1 = 13

Value 13 is D. For 0110:

8×0+4×1+2×1+0=68 \times 0 + 4 \times 1 + 2 \times 1 + 0 = 6

The result is D6.

In hexadecimal-to-binary mode, the default two digits are A and 5. The calculator joins them as A5, expands A to 1010 and 5 to 0101, then displays 10100101. It keeps the four-bit group for 5 as 0101 rather than 101 so the original two hex digits can be reconstructed.

Applications and interpretation

Hexadecimal is a readability layer over binary. A 16-bit mask such as 1111111100000000 is easier to scan as FF00. A color channel pair such as FF in a web color means the 8-bit channel is at its maximum value, which connects this converter to the color format converter calculator. If you are exploring powers of ten and powers of two in scientific work, the scientific notation calculator helps with a different compact notation. For random bit patterns, test cases, or examples, the random number generator can provide values to convert.

The calculator is intentionally small: binary input is limited to 16 bits, and hex input is limited to four digits. That range covers a nibble, a byte, and common 16-bit examples while keeping the page focused on the representation. Larger conversions follow the same grouping rule.

Edge cases and common mistakes

The most common error is grouping from the left. Binary place values are anchored at the right, so grouping must start there. If you group 101101 from the left as 101 101, you have created two three-bit groups and the wrong hex result. Correct padding gives 0010 1101, which is 2D.

Another mistake is discarding leading zeros when width matters. The unsigned values A and 0A are the same number, but they do not necessarily mean the same thing in a byte-oriented display. In a fixed-width register, 000A communicates that four hex digits are being shown. In the calculator, the binary input uses a numeric field, so typed leading zeros may not be preserved by the browser before conversion. Treat the page as a value converter, not as a fixed-width binary editor.

A final mistake is confusing symbols with values. The hex digit F has decimal value 15; it is not a variable name. Hex 10 equals decimal 16 because the 1 is in the sixteens place. Keeping the base in mind prevents off-by-a-factor errors when reading addresses, masks, or encoded color bytes.

Sources

  • Wolfram MathWorld, Binary — mathematical overview of base-2 notation.
  • Wolfram MathWorld, Hexadecimal — definition and digit set for base-16 notation.
  • Khan Academy, The binary number system — introductory explanation of binary place value.

Frequently asked questions

How do I convert binary to hexadecimal?
Group the binary digits into blocks of four starting from the right. Add leading zeros to the leftmost block only if it has fewer than four bits. Convert each four-bit block to its single hexadecimal digit, then read the digits in the same left-to-right order.
Why does one hexadecimal digit equal four binary digits?
Binary is base 2 and hexadecimal is base 16. Since 16 equals 2 to the fourth power, four binary places have exactly the same number of combinations as one hexadecimal place. That is why each hex digit maps cleanly to one four-bit group.
Can the calculator convert hexadecimal to binary?
Yes. Select hexadecimal to binary, choose one to four hexadecimal digits, and the calculator expands each digit into a four-bit binary group. For example, A becomes 1010 and 5 becomes 0101, so A5 becomes 10100101 in the displayed result.
Does padding change the value of a binary number?
Leading zero padding does not change the numeric value. Binary 1010 and 00001010 both represent decimal 10. Padding matters because it preserves a chosen bit width, such as 8 bits for a byte or 16 bits for a register, but the unsigned value is unchanged.
What inputs are allowed?
Binary mode accepts only zeros and ones and rejects values longer than 16 bits. Hexadecimal mode uses selectable digits from 0 through F and accepts one to four digits. The current binary field is numeric, so it is not ideal for preserving leading zeros typed by the user.

Related calculators

Binary to Hexadecimal Calculator updated at