Skip to main content

log2

Description

Returns the base-2 logarithm of a number. Equivalent to log(2, number).

Syntax

Like many functions in DataPrime, log2 supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.

log2(number: number): number

Arguments

NameTypeRequiredDescription
numbernumbertrueThe value whose base-2 logarithm will be computed

Example

Use case: Apply a log base 2 transformation

Compute the log base 2 of a numerical field and store the result in a new field.

Example data

{
"some_value": 16
}

Example query

create log_field from log2(some_value)

Example output

{
"some_value": 16,
"log_field": 4
}
Was this page helpful?