Contact

BIN2HEX in Excel: Convert Binary Fields and Preserve Signed Values

Engineering Intermediate Microsoft Excel

Convert binary strings to hexadecimal in Excel, choose padded widths and verify sign extension from ten-bit inputs to forty-bit negative outputs.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: BIN2HEX(number,[places]) converts a binary representation to hexadecimal. Positive results use the minimum width unless places is supplied; negative ten-bit inputs become ten-character hexadecimal values.

Availability and version history

  • Introduced: the first introduction version is not established by the reviewed official history.
  • Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
  • Checked: October 14, 2026; official BIN2HEX reference. Documentation and independent models; no native Excel execution or wider platform certification.

Syntax and the two different widths

=BIN2HEX(number,[places])

The binary input has at most ten characters and uses ten-bit two’s complement. Its signed interval is −512 through 511. An invalid binary representation or more than ten input characters produces documented #NUM! behavior.

The optional places argument controls the nonnegative output width. Too few places produces #NUM!; fractional places is truncated, nonnumeric places produces #VALUE!, and negative places produces #NUM!. The reference does not separately resolve zero places or every invalid-argument combination.

For negative inputs, the output is ten hexadecimal characters and places is ignored. Ten input binary bits and ten output hexadecimal characters are different widths: the latter represents forty bits. The signed quantity is preserved by extending its negative representation, not by simply grouping the original ten bits into short hex.

Example 1: convert a compact binary import

Format A2:A6 as Text and enter these strings. Put =BIN2HEX(A2) in B2 and =BIN2HEX(A2,4) in C2; fill both down.

Only the first table column is input data. The Decimal check column is explanatory and is not pasted into B; put calculated outputs in the worksheet cells specified above.

Binary text Decimal check Minimum hex Width 4
1010 10 A 000A
101101 45 2D 002D
11110000 240 F0 00F0
100000001 257 101 0101
0111111111 511 1FF 01FF

For 101101, group the positive bits from the right as 0010 1101. These groups represent 2 and 13, giving 2D. For 100000001, padding the illustration to 0001 0000 0001 gives 101.

That grouping check works for these nonnegative inputs. It must not replace the signed conversion rule for a full ten-bit negative input.

Example 2: inspect negative sign extension

Formula Expected hexadecimal
=BIN2HEX("1111111111") FFFFFFFFFF
=BIN2HEX("1111111101") FFFFFFFFFD
=BIN2HEX("1000000000") FFFFFFFE00

The binary quantities are −1, −3 and −512. An independent forty-bit encoding adds 2^40 to each negative quantity before converting the resulting unsigned value to ten hex positions.

Simply grouping 1111111111 as an unsigned binary number would give 3FF, which is positive 1023. That would change the quantity rather than convert its signed representation. Use BIN2DEC and HEX2DEC to inspect the signed decimal meaning on both sides.

A valid width such as 4 does not shorten a negative output: =BIN2HEX("1111111101",4) still gives FFFFFFFFFD. This example does not certify how an invalid width interacts with a negative input.

Advanced example: audit a conversion pipeline

Keep the first table in A2:C6. In D2 use =BIN2DEC(A2) and in E2 use =HEX2DEC(C2), then fill down. Both columns return 10, 45, 240, 257 and 511.

In F2 enter =D2=E2 and fill down. All five comparisons are TRUE. This checks preservation of the quantity while the display base and padded width change.

For a reverse conversion, =HEX2BIN(C2,10) yields a ten-position binary field. On the first row the result is 0000001010, which has the same quantity as the original 1010 but a different text width. HEX2BIN cannot recover an original width that was not retained.

If a downstream file requires the exact original character count, keep A or store that count separately. A numeric round-trip and a character-for-character round-trip are different tests.

Padding, errors and scope checks

=BIN2HEX("101101",4.9) uses truncated width 4 and produces 002D. =BIN2HEX("100000001",2) needs three hexadecimal positions and follows the documented #NUM! rule.

=BIN2HEX("102") contains an invalid binary digit. An eleven-character string such as 00000000001 also exceeds the stated input width, even though its positional value would be small.

Use DEC2HEX when the source is already a decimal integer. The literal decimal quantity 45 and the binary text 101101 represent the same amount through different input contracts. Native text cleanup, locale effects and unspecified argument-error precedence were not executed here.

References and verification

Expected outputs are independently calculated examples or documented rules, not captured native Excel results. Formulas use English function names and comma argument separators. Locale, rendering and boundary restrictions are stated where relevant.