---
source: https://carbone.io/documentation/design/computation/simple-mathematics.html
title: "Simple addition, subtraction, multiplication..."
description: "Simple addition, subtraction, multiplication, division"
generated_at: "2026-07-10"
---

# Simple Mathematics

Simple addition, subtraction, multiplication, division  
COMMUNITY FEATURE Available for:  
✓ Carbone Cloud  
✓ Carbone On-premise  
✓ Embedded Carbone JS   v4.0+ 

## With formatters

Here is the list of formatters that can be used to perform simple operations:

-   [add (value)](/documentation/design/formatters/number.md#add-value) : Addition
-   [mul (value)](/documentation/design/formatters/number.md#mul-value) : Multiplication
-   [sub (value)](/documentation/design/formatters/number.md#sub-value) : Subtraction
-   [div (value)](/documentation/design/formatters/number.md#div-value) : Division
-   [mod (value)](/documentation/design/formatters/number.md#mod-value) : Modulo
-   [abs (value)](/documentation/design/formatters/number.md#abs) : Get absolute value

## Mathematical formula

Formatters `add()`, `mul()`, `sub()` and `div()` accept simple mathematical expressions inside parentheses.

-   Only mathematical operators `+, *, -, /` are allowed, **without parentheses**
-   Multiplication and division operators (`*`, `/`) have higher precedence than the addition/subtraction operators (`+`, `-`) and thus will be evaluated first.

**Examples:**

```cdata
{
  "val"      : 1,
  "otherQty" : 2,
  "vat"      : 0.5,
  "sub"      : {
    "price" : 100
  }
}
```

```ctemplate
{d.val:add(.otherQty + .vat * d.sub.price - 10 / 2)}
```

```cresult
48
```

## Arithmetic precision

By default, calculations use double-precision floating-point numbers based on the 64-bit IEEE-754 standard.

To avoid [floating-point precision issues](https://floating-point-gui.de/), as of version 4.22.4, you can use the option `{o.useHighPrecisionArithmetic=true}` within a template to enable arbitrary-precision decimal arithmetic for mathematical operations.

When this option is included in the template, the formatters `:add`, `:sub`, `:mul`, `:div`, `:formatC`, and `:formatN` will maintain full decimal precision, up to a maximum of 20 decimal places.

## Related topics

- [Store and transform](/documentation/design/computation/store-and-transform.md)
- [Aggregators](/documentation/design/computation/aggregation.md)
