apoc.math.round
Function APOC Core
apoc.math.round(value,[prec],mode=[CEILING,FLOOR,UP,DOWN,HALF_EVEN,HALF_DOWN,HALF_UP,DOWN,UNNECESSARY])
Signature
apoc.math.round(value :: FLOAT?, precision = 0 :: INTEGER?, mode = HALF_UP :: STRING?) :: (FLOAT?)
Usage Examples
Taken from the Java official API, these are the rounding mode options:
CEILING |
Rounding mode to round towards positive infinity. |
FLOOR |
Rounding mode to round towards negative infinity. |
UP |
Rounding mode to round away from zero. |
DOWN |
Rounding mode to round towards zero. |
HALF_EVEN |
Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. |
HALF_DOWN |
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. |
HALF_UP |
Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up. |
UNNECESSARY |
Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. In cases where rounding would occur, a |
RETURN apoc.math.round(1.783, 0, "HALF_UP") AS output;
output |
---|
2.0 |
RETURN apoc.math.round(1.783, 0, "DOWN") AS output;
output |
---|
1.0 |
This function has been deprecated and will be removed in version 5.0. Use Neo4j’s |