Design
Simple Mathematics
Simple addition, substraction, multiplications, 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) : Addition
- mul (value) : Multiplication
- sub (value) : Subtraction
- div (value) : Division
- mod (value) : Modulo
- abs (value) : Get absolute value
Mathematical formula
Formatters add()
, mul()
, sub()
and div()
accept simple mathematical expressions inside parenthesis.
- Only mathematical operators
+, *, -, /
are allowed, without parenthesis - Multiplication and division operators (
*
,/
) has higher precedence than the addition/subtraction operator (+
,-
) and thus will be evaluated first.
Examples:
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, 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.