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
ParameterTypeRequiredDescription
decimal_numberTYesDecimal integer to convert
baseBYesTarget 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 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
1010FF777101010

Last update at: 2026/05/26 17:22:09