---
title: `log2`
url: https://nexyron.tech/docs/cypher/functions/numeric/log2
description: Computes a base 2 logarithm for positive numeric values. It is documented separately because numeric transforms change ranking, thresholds, and buckets in ways planner tools must n
---

# `log2`

## Generic Description

Computes a base-2 logarithm for positive numeric values. It is documented separately because numeric transforms change ranking, thresholds, and buckets in ways planner tools must not guess.

Simple example:

```cypher
RETURN log2(8.0) AS value
```

## Consumer-Level Explanation

Use it for doubling-scale interpretations such as capacity, fanout, or binary growth. Prefer this function when the transformation is a deliberate part of the model or report, and name the derived value in a `WITH` stage when it will be reused.

## More Detailed Explanation

`log2` is scalar math, so it is evaluated per row after graph patterns, procedure output, or map projections have produced values. Keep it close to the query when thresholds, ranking, and derived fields need to be auditable and reproducible.

## Advanced Example

This example applies `log2` to a named score component after matching graph data, making the derived metric reviewable before ordering.

```cypher
MATCH (d:Document)
WITH d, properties(d).prize + 1.0 AS adjusted_priority
RETURN d.title AS document,
       log2(adjusted_priority) AS doubling_scale_priority
ORDER BY doubling_scale_priority DESC
```

## Real Use Cases

-   distance-from-target scoring
-   numeric bucketing and normalization before `ORDER BY` or aggregation
-   making scoring formulas visible to query review and assistant tooling

## Real Limitations And Tradeoffs

-   invalid numeric inputs produce null-like results rather than a repaired value
-   math functions do not fix poor feature scaling; choose transformations intentionally
-   nondeterministic functions such as random sampling are not appropriate for persisted decisions
