TO_BASE
All functions > MATH > TO_BASE
Returns the string representation of a decimal number in a specified base.
Signatures
Returns: String representation in the target base
TO_BASE(decimal_number: BIGINT, base: BIGINT) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
decimal_number | BIGINT | Yes | The decimal (base 10) number to convert |
base | BIGINT | Yes | The target base (2-36) |
Notes
- Supports bases from 2 (binary) to 36
- For bases > 10, uses letters A-Z for digits 10-35
- Returns uppercase letters for bases > 10
- Returns NULL if decimal_number is NULL
- Useful for converting to binary, octal, hexadecimal
Examples
FeatureQL
SELECT
f1 := TO_BASE(10, 2), -- Decimal to binary
f2 := TO_BASE(255, 16), -- Decimal to hexadecimal
f3 := TO_BASE(511, 8), -- Decimal to octal
f4 := TO_BASE(42, 2) -- 42 in binary
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR | f4 VARCHAR |
|---|---|---|---|
| 1010 | FF | 777 | 101010 |
On this page