Exact Math
Functions for high precision arithmetic
| Qualified Name | Type |
|---|---|
|
Function |
|
Function |
|
Function |
|
Function |
|
Function |
|
Function |
|
Function |
-
Possible
roundingModeoptions areUP,DOWN,CEILING,FLOOR,HALF_UP,HALF_DOWN,HALF_EVEN,UNNECESSARY.
The precision parameter allows users to set the precision of the operation result.
The default value of the precision parameter is 0 (unlimited precision arithmetic), while for roundingMode the default value is HALF_UP.
For more information abouth the precision and roundingMode parameters, see Java’s MathContext page.
Examples
In the below example, the precision parameter is set to 2. Consequently, only the first two digits of the returned result are precise.
RETURN apoc.number.exact.div('5555.5555','5', 2, 'HALF_DOWN') as value;
| Value |
|---|
1100 |
In the below example, the precision parameter is set to 8. The first eight digits of the returned result are therefore precise.
RETURN apoc.number.exact.div('5555.5555','5', 8, 'HALF_DOWN') as value;
| Value |
|---|
1111.1111 |
These functions accept scientific notation as input. For example:
RETURN apoc.number.exact.add('1E6','1E6') as value;
| Value |
|---|
2000000 |
For more information, see Java’s BigDecimal page and Java’s BigInteger page.