BIN2OCT Function (LibreOffice Calc)
The BIN2OCT function converts a binary (base‑2) number into its octal (base‑8) equivalent. Supports signed 10‑bit binary values using two’s complement.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✔ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✖ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the BIN2OCT Function Does ▾
- Converts binary → octal
- Accepts up to 10 bits
- Supports signed values using two’s complement
- Useful for encoding, bitwise workflows, and low‑level numeric processing
Syntax ▾
BIN2OCT(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 octal
=BIN2OCT("111")
→ "7"
Convert using a cell reference
=BIN2OCT(A1)
Convert a signed 10‑bit binary number
=BIN2OCT("1111111111")
→ "7777777777" (Excel-compatible 30‑bit octal)
Pad output to a minimum length
=BIN2OCT("1010"; 4)
→ "0012"
Advanced Examples ▾
Convert binary stored as text
=BIN2OCT(TEXT(A1; "0000000000"))
Convert binary from DEC2BIN
=BIN2OCT(DEC2BIN(A1; 10))
Convert binary from BIT* functions
=BIN2OCT(BASE(BITAND(A1; A2); 2; 10))
Convert a two’s‑complement negative number
=BIN2OCT("1111110110")
→ "7777777756"
Convert padded binary string
=BIN2OCT(RIGHT("0000000000" & A1; 10))
Edge Cases and Behavior Details ▾
BIN2OCT returns an octal text string
Accepts:
- Binary strings up to 10 bits
- Signed values using two’s complement
- Leading zeros
- Optional padding
Behavior details
- Octal digits range from 0–7
- Negative binary values produce 30‑bit octal (Excel compatibility)
- Positive values produce minimal-length octal unless padded
- Input must be text or a number containing only 0s and 1s
Invalid input → Err:502
BIN2OCT 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 octal output
Cause:
- Input interpreted as signed two’s complement
Fix:
- Ensure correct bit width
- Use DEC2OCT for unsigned octal
Best Practices ▾
- Pad binary values to 10 bits for predictable signed behavior
- Use DEC2OCT for unsigned octal conversions
- Combine with BIT* functions for bitwise workflows
- Validate binary input to avoid Err:502
- Use BASE for arbitrary‑length binary/octal conversions
BIN2OCT is ideal for bridging binary and octal workflows — perfect for encoding, bitwise operations, and low‑level numeric processing.
Related Patterns and Alternatives ▾
- Use BIN2DEC and BIN2HEX for other conversions
- Use DEC2OCT for decimal → octal
- Use OCT2DEC for octal → decimal
- Use BASE for arbitrary‑base conversions
- Use VALUE to sanitize imported text
By mastering BIN2OCT and its companion functions, you can build powerful binary‑processing and encoding workflows in LibreOffice Calc.