HEX2BIN
Converts a hexadecimal text value to binary text.
Supports optional left-padding through the places argument.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=HEX2BIN(number, [places])
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
number | any | Required | — |
places | any | Optional | — |
Return type
Can return text.
Remarks
- Input must be hexadecimal text up to 10 characters and may be signed two's-complement.
placesmust be at least the output width and at most10, or#NUM!is returned.
Error cases
- The converted decimal value must be in
[-512, 511], or the function returns#NUM!.
Examples
Convert hexadecimal 1E with no output padding.
Formula =HEX2BIN("1E")
Expected result 11110
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use eight output characters to preserve leading zeros.
Formula =HEX2BIN("1E",8)
Expected result 00011110
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Convert zero with a one-place width.
Formula =HEX2BIN("0",1)
Expected result 0
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
The input contains an invalid hexadecimal digit.
Formula =HEX2BIN("G")
Expected result #NUM!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Convert positive hex to binary
Formula =HEX2BIN("1F")
Expected result 11111
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Convert signed hex
Formula =HEX2BIN("FFFFFFFFFF")
Expected result 1111111111
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
Why can valid hex text still produce #NUM! in HEX2BIN?
After conversion, the decimal value must fit [-512, 511]; otherwise binary output is rejected.