> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Calculates the sum of the numbers with Kahan compensated summation algorithm

# sumKahan

<h2 id="sumKahan">
  sumKahan
</h2>

Introduced in: v1.1.0

Calculates the sum of the numbers with [Kahan compensated summation algorithm](https://en.wikipedia.org/wiki/Kahan_summation_algorithm).
Slower than [`sum`](/reference/functions/aggregate-functions/sum) function.
The compensation works only for [Float](/reference/data-types/float) types.

**Syntax**

```sql theme={null}
sumKahan(x)
```

**Arguments**

* `x` — Input value. [`Integer`](/reference/data-types/int-uint) or [`Float`](/reference/data-types/float) or [`Decimal`](/reference/data-types/decimal)

**Returned value**

Returns the sum of numbers. [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`Decimal`](/reference/data-types/decimal)

**Examples**

**Demonstrating precision improvement with Kahan summation**

```sql title=Query theme={null}
SELECT sum(0.1), sumKahan(0.1) FROM numbers(10);
```

```response title=Response theme={null}
┌───────────sum(0.1)─┬─sumKahan(0.1)─┐
│ 0.9999999999999999 │             1 │
└────────────────────┴───────────────┘
```
