BIN2HEX Function (LibreOffice Calc)
The BIN2HEX function converts a binary (base‑2) number into its hexadecimal (base‑16) equivalent. Supports signed 10‑bit binary values using two’s complement.
Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked
Availability and version history
- Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
- Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
The **BIN2HEX** function converts a **binary number** (base‑2) into a **hexadecimal number** (base‑16). It supports both unsigned and signed 10‑bit binary values using **two’s complement** representation.
What the BIN2HEX Function Does
- Converts binary → hexadecimal
- Accepts up to 10 bits
- Supports signed values using two’s complement
- Useful for encoding, bitwise workflows, and low‑level data processing
Syntax
BIN2HEX(binary_number; [min_length])
Arguments
-
binary_number:
A text string representing a binary number (e.g.,"1011"). -
min_length (optional):
Minimum output length (pads with leading zeros).
Basic Examples
Convert simple binary to hex
=BIN2HEX("1111")
→ "F"
Convert using a cell reference
=BIN2HEX(A1)
Convert a signed 10‑bit binary number
=BIN2HEX("1111111111")
→ "FFFFFFFFFF" (Excel-compatible 40‑bit hex)
Pad output to a minimum length
=BIN2HEX("1010"; 4)
→ "000A"
Advanced Examples
Convert binary stored as text
=BIN2HEX(TEXT(A1; "0000000000"))
Convert binary from DEC2BIN
=BIN2HEX(DEC2BIN(A1; 10))
Convert binary from BIT* functions
=BIN2HEX(BASE(BITXOR(A1; A2); 2; 10))
Convert a two’s‑complement negative number
=BIN2HEX("1111110110")
→ "FFFFFFFE6"
Convert padded binary string
=BIN2HEX(RIGHT("0000000000" & A1; 10))
Edge Cases and Behavior Details
BIN2HEX returns a hexadecimal text string
Accepts:
- Binary strings up to 10 bits
- Signed values using two’s complement
- Leading zeros
- Optional padding
Behavior details
- Hex output uses uppercase A–F
- Negative binary values produce 40‑bit hex (Excel compatibility)
- Positive values produce minimal-length hex unless padded
- Input must be text or a number containing only 0s and 1s
Invalid input → Err:502
BIN2HEX of an error → error propagates
Common Errors and Fixes
Err:502 — Invalid binary number
Cause:
- Contains characters other than 0 or 1
- More than 10 bits
- Empty string
Fix:
- Validate input
- Use TEXT or RIGHT to enforce 10‑bit width
Unexpected long hex output
Cause:
- Input interpreted as signed two’s complement
Fix:
- Ensure correct bit width
- Use DEC2HEX for unsigned hex
Best Practices
- Pad binary values to 10 bits for predictable signed behavior
- Use DEC2HEX for unsigned hex conversions
- Combine with BIT* functions for bitwise workflows
- Validate binary input to avoid Err:502
- Use BASE for arbitrary‑length binary/hex conversions
BIN2HEX is ideal for bridging binary and hexadecimal workflows — perfect for encoding, bitwise operations, and low‑level numeric processing.
Related Patterns and Alternatives
- Use BIN2DEC and BIN2OCT for other conversions
- Use DEC2HEX for decimal → hex
- Use HEX2DEC for hex → decimal
- Use BASE for arbitrary‑base conversions
- Use VALUE to sanitize imported text
By mastering BIN2HEX and its companion functions, you can build powerful binary‑processing and encoding workflows in LibreOffice Calc.