Skip to content

toBase - Change base of numerical value

The toBase function will render out a string representation of a number.

Syntax

toBase(number: number, radix: number): string

Arguments

Name Type Required Description
number number true The number to convert into its string representation
radix number true The base for the new stringified number. e.g hexidecimal is 16

Example - Converting a number to hexidecimal

Consider the following document:

{
    "val": 10
}

If we wish to convert val into a hex representation, we can use toBase:

create val_hex from val.toBase(16)

This results in the following document:

{
    "val": 10,
    "val_hex": "a"
}

Try it yourself

Open the Explore screen in Coralogix and paste this query:

create val from 10
| create val_hex from val.toBase(16)