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.
- Function notation
- Method notation
log2(number: number): number
(number: number).log2(): number
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
number | number | true | The 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
- Function notation
- Method notation
create log_field from log2(some_value)
create log_field from some_value.log2()
Example output
{
"some_value": 16,
"log_field": 4
}