HEX2BIN in Excel: Convert Hex Bytes and Respect the Binary Range
Convert hexadecimal text to binary in Excel, verify padding and distinguish forty-bit signed inputs from the narrower ten-bit output range.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2BIN(number,[places]) converts hexadecimal notation to binary, but its output quantity must fit the signed ten-bit interval −512 through 511. A valid hexadecimal input is not automatically eligible for this narrower target format.
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 HEX2BIN reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and source-width correction
=HEX2BIN(number,[places])
The input is at most ten hexadecimal characters, interpreted with a forty-bit sign convention. Microsoft gives positive maximum 1FF and negative minimum FFFFFFFE00 for this conversion, corresponding to 511 and −512.
The reference calls the sign bit the fortieth bit, then incorrectly describes only nine remaining bits. Ten hexadecimal characters contain forty bits; the relevant unsigned width is therefore forty, not ten. Its stated endpoints and worked negative conversion establish the intended signed interpretation.
Places is optional and pads positive output with leading zeros. Omission uses the minimum width. Too few places produces #NUM!; fractional places is truncated, nonnumeric places produces #VALUE!, and negative places produces #NUM!. Invalid hex produces #NUM!. Zero places and every boundary-error precedence are not separately established here.
Example 1: inspect byte-sized hex fields
Format A2:A6 as Text and enter the following. In B2 use =HEX2BIN(A2,8) and fill 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.
| Hex | Decimal check | Eight-position binary |
|---|---|---|
| 0A | 10 | 00001010 |
| 2D | 45 | 00101101 |
| 80 | 128 | 10000000 |
| B7 | 183 | 10110111 |
| FF | 255 | 11111111 |
Each hex digit maps to four binary positions. For 2D, the groups are 0010 and 1101. For B7, they are 1011 and 0111. The eight-character FF output remains positive in the converter’s ten-bit signed format.
In C2 use =HEX2DEC(A2) and in D2 use =BIN2DEC(B2), then fill down. Both columns return 10, 45, 128, 183 and 255, verifying the quantities independently of their representation.
Example 2: show the narrower target limit
=HEX2BIN("1FF",10) gives 0111111111, representing 511. The next positive hexadecimal value 200 represents 512 and lies outside the documented conversion interval.
Increasing places cannot expand that interval. A request for ten or more displayed positions does not change the function into an unsigned arbitrary-width converter. The dedicated reference specifies the allowed endpoints; this guide does not assign an unlisted exact error for every out-of-range case.
For a larger positive value, HEX2DEC can first expose the decimal quantity, and a different representation function can be considered under its own rules. Do not silently truncate the high bits to force an output.
Advanced example: negative quantities change representation width
| Hexadecimal input | Signed quantity | Expected binary |
|---|---|---|
| FFFFFFFFFF | -1 | 1111111111 |
| FFFFFFFFFD | -3 | 1111111101 |
| FFFFFFFE00 | -512 | 1000000000 |
The negative input uses forty-bit two’s complement, while the output uses ten bits. For −3, the input’s unsigned representation is 2^40−3 and the output’s unsigned representation is 2^10−3=1021. Both encode the same signed quantity.
Places is ignored for a negative value. =HEX2BIN("FFFFFFFFFD",4) still produces 1111111101. The valid width argument does not request a four-bit signed result.
Contrast the short input FD, representing positive 253. =HEX2BIN("FD",8) gives 11111101. It does not represent −3 in this function’s signed format; the source width must be interpreted correctly.
Advanced check: round-trip without claiming original padding
For each positive row in the first table, =BIN2HEX(B2,2) reconstructs the two-character hex field. The expected outputs are 0A, 2D, 80, B7 and FF.
If the original input were 000A, the same width-two reverse formula would return 0A. The quantity is preserved, but the original leading-zero count is not. BIN2HEX uses its requested output width rather than remembering the original string.
Errors and reliable setup
=HEX2BIN("2D",4) needs six binary positions and follows the documented insufficient-width #NUM! rule. Places 8.9 is truncated to 8 and gives 00101101. The invalid input G1 produces the documented hexadecimal #NUM! condition.
Use Text formatting or quoted constants for representation inputs. BIN2DEC helps verify the signed output meaning. Prefix acceptance, lowercase variants and native error precedence were not executed in this guide; all worked hex strings use explicit uppercase notation.
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.