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
ParameterTypeRequiredDescription
decimal_numberBIGINTYesThe decimal (base 10) number to convert
baseBIGINTYesThe 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 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
1010FF777101010

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19