BASE Function (LibreOffice Calc)
The BASE function converts a number into a text string representing that number in a specified base (radix). It supports bases from 2 to 36 and optional minimum length padding.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✔ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✖ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the BASE Function Does ▾
- Converts a number to a text string in a chosen base
- Supports bases from 2 to 36
- Supports optional minimum length (pads with leading zeros)
- Useful for encoding, identifiers, and number-system conversions
It is designed to be simple, flexible, and ideal for text-based numeric representation.
Syntax ▾
BASE(number; radix; [min_length])
Arguments
-
number:
The non-negative integer to convert. -
radix:
The base (2 to 36). -
min_length: (optional)
Minimum output length; pads with leading zeros if needed.
Basic Examples ▾
Convert to binary
=BASE(10; 2)
Returns "1010".
Convert to hexadecimal
=BASE(255; 16)
Returns "FF".
Convert to octal
=BASE(64; 8)
Returns "100".
Convert to base 36
=BASE(12345; 36)
Returns "9IX".
Pad to minimum length
=BASE(10; 2; 8)
Returns "00001010".
Advanced Examples ▾
Generate fixed-width binary codes
=BASE(A1; 2; 16)
Create compact alphanumeric IDs
=BASE(A1; 36)
Convert row numbers to base-26 letters (A, B, C…)
=BASE(ROW(); 26)
Create padded hex identifiers
=BASE(A1; 16; 4)
Convert timestamps to base-36 tokens
=BASE(NOW()*86400; 36)
Build structured codes
=CONCAT("ID-"; BASE(A1; 36; 6))
Convert decimal to binary with grouping
=TEXTJOIN(" "; TRUE; MID(BASE(A1; 2; 16); {1;5;9;13}; 4))
Generate bitmasks
=BASE(2^A1; 2)
Convert to base-N and uppercase
=UPPER(BASE(A1; B1))
Edge Cases and Behavior Details ▾
number must be non-negative
Negative numbers → Err:502.
radix must be between 2 and 36
=BASE(10; 1) → Err:502
=BASE(10; 37) → Err:502
min_length < output length → ignored
min_length < 0 → Err:502
Output is always text
=TYPE(BASE(10; 2)) → 2 (text)
BASE does not accept fractional numbers
=BASE(3.14; 2) → Err:502
BASE of an error propagates the error
Letters A–Z represent digits 10–35
BASE is case-insensitive but outputs uppercase
Common Errors and Fixes ▾
Err:502 — Invalid argument
Occurs when:
- number < 0
- radix outside 2–36
- min_length negative
- number not integer
Unexpected output length
Cause:
- min_length smaller than actual output
- number too large
Lowercase expected but uppercase returned
Fix:
- Wrap with LOWER()
Best Practices ▾
- Use BASE for compact identifiers and encodings
- Use min_length for fixed-width formatting
- Use BASE with TEXTJOIN for grouped binary/hex output
- Use BASE with ROW() or RAND() for unique tokens
- Use BASE for cross-system numeric representation
- Use BASE with UPPER/LOWER for stylistic control
BASE is your number‑system converter — perfect for binary, hex, octal, base‑36 IDs, and any workflow where numbers must become structured text.
Related Patterns and Alternatives ▾
- Use DEC2BIN, DEC2HEX, DEC2OCT for specialized conversions
- Use ROMAN and ARABIC for numeral-system conversion
- Use TEXT for formatting numbers as text
- Use REPT for padding
- Use UNICODE and UNICHAR for character-level encoding
By mastering BASE and its companion functions, you can build powerful, structured, and encoding-aware text workflows in LibreOffice Calc.