Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Flog2.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fdocs-docusaurus.kinsta.page%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Flog2.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `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](https://docs-docusaurus.kinsta.page/dataprime/language-reference/functions-reference/.md),<!-- --> **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

}
```
