TO_BASE()
All functions > MATH > TO_BASE()
Returns the string representation of a decimal number in a specified base.
Signatures
To base
Returns: String representation in the target base
TO_BASE(decimal_number: T, base: B) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
decimal_number | T | Yes | Decimal integer to convert |
base | B | Yes | Target base, from 2 to 36 |
With:
T: Integer type (TINYINT … BIGINT)B: Integer type (TINYINT … BIGINT)
Signature notes:
- Supports bases from 2 (binary) to 36
- For bases > 10, returns uppercase letters A-Z for digits 10-35
- Returns NULL if decimal_number is NULL
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