Skip to 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 notation. These interchangeable forms allow flexibility in how you structure expressions.

log2(number: number): number
(number: number).log2(): 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.

{
    "some_value": 16
}
create log_field from log2(some_value)
create log_field from some_value.log2()

Output

{
    "some_value": 16,
    "log_field": 4
}