BIN2HEX in Google Sheets: Convert Binary Text and Audit Signed Hex
Convert binary fields to hexadecimal in Google Sheets, pad positive outputs and verify signed quantities without treating encoded digits as decimal.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: BIN2HEX(signed_binary_number,[significant_digits]) converts a signed binary representation to hexadecimal. Supply a width to preserve a fixed positive field size, and decode results before using ordinary arithmetic.
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 BIN2HEX reference. Documentation and independent models, with no native Sheets execution or wider client certification.
Syntax and input meaning
=BIN2HEX(signed_binary_number,[significant_digits])
Google specifies a ten-bit signed input, with two’s-complement negatives. The documented positive maximum 0111111111 represents 511; the negative endpoint 1000000000 represents −512. A shorter positive string such as 11 represents three, not decimal eleven.
The reference accepts a string or a valid numeric digit representation converted to that string. Thus =BIN2HEX(11111) and =BIN2HEX("11111") both produce 1F, representing decimal 31. This conversion of input digits does not mean that the function accepts arbitrary decimal quantities as binary.
The optional second argument pads a nonnegative result with leading zeros. A requested width smaller than the required result produces documented #NUM!. Negative signed inputs ignore the padding count. Fractional widths, zero widths and general text-cleanup behavior are not established by this reference; the examples use positive integer widths.
Example 1: convert an imported binary field
Format A2:A6 as Plain text and enter only the first column below. Put =BIN2HEX(A2,4) in B2 and fill through B6. The decimal column is explanatory, not worksheet input.
| A, binary text | B, expected hex | Decimal check |
|---|---|---|
| 11 | 0003 | 3 |
| 10101 | 0015 | 21 |
| 1000001 | 0041 | 65 |
| 11000000 | 00C0 | 192 |
| 101101010 | 016A | 362 |
The last positive field groups from the right as 0001 0110 1010. Those four-bit groups give hex digits 1, 6 and A. The extra leading zero in 016A comes from the requested four-character width.
In C2 use =BIN2DEC(A2) and in D2 use =HEX2DEC(B2), filling both down. Both columns return 3, 21, 65, 192 and 362. This verifies the quantity independently of its representation.
Example 2: preserve a negative quantity
| Formula | Expected hex |
|---|---|
=BIN2HEX("1111111111",4) |
FFFFFFFFFF |
=BIN2HEX("1111111011",4) |
FFFFFFFFFB |
=BIN2HEX("1000000000",4) |
FFFFFFFE00 |
The signed quantities are −1, −5 and −512. These expected outputs use the forty-bit signed hexadecimal model documented by HEX2DEC. For −5, add 2^40 to −5 and express the result in ten hex positions.
Padding does not shorten a negative representation. Simply treating 1111111011 as an unsigned quantity would instead give 1019, or hex 3FB. That changes the meaning. A negative conversion must preserve the signed value, not merely regroup the input digits without considering their sign.
Advanced example: arithmetic after conversion
Enter binary text 100010001 in F2 and =BIN2HEX(F2,3) in G2. The result is 111, representing decimal 273. Add decimal nine by decoding first:
=DEC2HEX(HEX2DEC(G2)+9,3)
Expected result: 11A, representing 282. In contrast, the ordinary expression =G2+9 treats the numeric-looking result as decimal and gives 120. Interpreting that string as hex would mean 288, a different quantity again.
This is why a successful formula evaluation is not sufficient evidence that a calculation used the intended base. Keep numeric quantities and encoded output labels in separate columns.
Advanced example: verify a round trip without losing field width
With the first fixture, =HEX2BIN(B2,10) returns a ten-position binary field. The first row becomes 0000000011. Its numeric value still equals three, but its text is no longer the original two-character string 11.
For a fixed-width interface, store the original field width or specify the required output width explicitly. A conversion can preserve the signed quantity while changing the character count. HEX2BIN also has a target range that must be respected; these five positive values fit.
Errors and boundary checks
=BIN2HEX("1012",4) contains an invalid binary digit and follows Google’s documented #NUM! rule. =BIN2HEX("101101010",2) cannot fit the required three hex digits and also produces documented #NUM! behavior.
Use DEC2HEX when the source is a decimal quantity such as 362. General coercion, combined-invalid-argument precedence and native precision limits were not tested here. The negative outputs are independently calculated signed-model controls, not captured Sheets results.
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.