HEX2BIN in Google Sheets: Decode Hex Fields into Signed Binary
Convert hexadecimal fields to binary in Google Sheets, respect the narrower target interval and separate numeric input digits from decimal quantities.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: HEX2BIN(signed_hexadecimal_number,[significant_digits]) converts signed hexadecimal text to binary. The target interval is −512 through 511 even though the input notation uses a forty-bit signed hexadecimal format.
Availability and version history
- Introduced: first introduction date is not established by the reviewed official history; no desktop release number is inferred.
- Availability: documented in the rolling Google Sheets service; these examples use the web worksheet workflow.
- Checked: October 14, 2026; official HEX2BIN reference. Documentation and independent models, with no native Sheets execution or wider client certification.
Syntax, target range and padding
=HEX2BIN(signed_hexadecimal_number,[significant_digits])
Google gives 1FF as the largest positive input and FFFFFFFE00 as the smallest negative input for this converter. Those represent 511 and −512. A valid hexadecimal string outside this narrower interval is not automatically a valid HEX2BIN input.
Hexadecimal letters are case-insensitive. The optional width adds leading zeros to a nonnegative result; a requested width smaller than the result requires produces documented #NUM!. Negative signed inputs ignore the supplied width.
The reference accepts valid numeric digit inputs by converting them to their corresponding strings. In particular, numeric 199 and text “199” both mean hexadecimal 199, or decimal 409. They do not mean decimal 199. The documented binary result is 110011001.
Example 1: expand positive hex bytes
Format A2:A6 as Plain text and enter only the first table column. In B2 use =HEX2BIN(A2,8) and fill down. The decimal checks are explanatory, not input data in B.
| A, hex | B, eight-bit field | Decimal check |
|---|---|---|
| 09 | 00001001 | 9 |
| 2A | 00101010 | 42 |
| 5C | 01011100 | 92 |
| A5 | 10100101 | 165 |
| F0 | 11110000 | 240 |
For 5C, hexadecimal 5 expands to 0101 and C expands to 1100. Joining these groups gives 01011100. For A5, the groups are 1010 and 0101.
These eight-character fields are positive under the converter family’s ten-bit signed convention. An initial one in an eight-character field does not by itself make it a ten-bit negative number.
In C2 use =HEX2DEC(A2) and in D2 use =BIN2DEC(B2), filling down. Both return 9, 42, 92, 165 and 240. BIN2DEC is the appropriate check for the encoded binary quantity.
Example 2: distinguish short hex from a signed negative
| Formula | Expected binary |
|---|---|
=HEX2BIN("FB",8) |
11111011 |
=HEX2BIN("FFFFFFFFFB",4) |
1111111011 |
=HEX2BIN("FFFFFFFE00",4) |
1000000000 |
Short FB represents positive 251. The full forty-bit FFFFFFFFFB represents −5 and produces a ten-bit negative result. The negative minimum produces −512. A valid padding count of four cannot shorten either negative output.
For −5, the independent ten-bit encoding is 2^10−5=1019, which is 1111111011 in binary. This arithmetic explains the output; it does not reinterpret the signed quantity as positive 1019 in the spreadsheet converter.
At the positive endpoint, =HEX2BIN("1FF",10) gives 0111111111. Hex 200 represents 512 and is outside the documented target interval. This guide does not assign an error code to every out-of-range case when the cited notes do not explicitly do so.
Advanced example: check a fixed-width round trip
With the first fixture, put =BIN2HEX(B2,2) in E2 and fill down. Expected results are 09, 2A, 5C, A5 and F0, matching the original uppercase two-position labels.
For a differently padded source, =BIN2HEX(HEX2BIN("0009",8),2) returns 09. The quantity is preserved, but the original four-character width is not. Keep the original text when exact input formatting matters.
Lowercase =HEX2BIN("a5",8) has the same expected output as uppercase A5. This is a documented hexadecimal-digit rule, not a promise about arbitrary string normalization.
Advanced example: add after decoding
Hex 1F represents decimal 31. =HEX2BIN("1F",5) gives 11111. To add decimal nine and return an eight-bit field, use:
=DEC2BIN(BIN2DEC(HEX2BIN("1F",5))+9,8)
Expected result: 00101000, representing 40. Adding nine directly to the visible digits 11111 would produce decimal 11120, which is not a binary representation at all.
When the original hex value is still available, =DEC2BIN(HEX2DEC("1F")+9,8) is a simpler equivalent workflow. HEX2DEC and DEC2BIN keep the quantity explicit.
Errors and evidence limits
=HEX2BIN("2G",8) contains an invalid hex character and follows the documented #NUM! rule. =HEX2BIN("2A",5) needs six binary digits and follows the too-small-width #NUM! rule.
The dedicated page does not establish fractional-width truncation, a zero-width rule or general blank/error coercion. The examples deliberately avoid importing those details from Excel. All signed conversions and field checks above are independently calculated controls, not native Sheets captures.
References and verification
Examples use fictional data, English function names and comma separators. Expected outputs are independent mathematical calculations or explicitly documented rules, not native Sheets captures. Check the spreadsheet locale when reproducing punctuation-sensitive formulas.