You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support round(expression, precision), round(expression, precision, mode) #309
@LiorKogan Please confirm if the given descriptions about different modes in this documentation are correct or not? I made changes as per this documentations definitions for all the modes.
I think there are some problems with their convention. Their naming makes sense only for positive numbers.
They also have a bug with HALF_DOWN and negative x.5 numbers.
I would suggest the following:
Keep compatibility with
CEILING
HALF_DOWN
HALF_EVEN
HALF_UP
but the following are simply wrong:
'DOWN' - Round towards zero. This is misleading. We should call it TOWARD_ZERO
'UP' - Round away from zero. This is misleading. We should call it AWAY_FROM_ZERO
'FLOOR' - Round towards zero. This is misleading. We should use the standard meaning of FLOOR
Origin comment by: @Khalid6468 @LiorKogan Done with the implementation. Please have a look at the PR #2668. Here are the sample outputs for the round function:
Origin comment by: @LiorKogan @Khalid6468 thank you. We'll review.
Please make sure there are tests specifically for -1.5, -0.5, 0.5, and 1.5.
Also for NaN, -INF, +INF, and large inputs (e.g., 1.7E308).
Activity
gkorland commentedon Sep 25, 2023
Origin comment by: @LiorKogan
https://neo4j.com/docs/cypher-manual/current/functions/mathematical-numeric/#functions-round2
gkorland commentedon Sep 25, 2023
Origin comment by: @exitflynn
i'd like to work on this issue!
gkorland commentedon Sep 25, 2023
Origin comment by: @Khalid6468
@LiorKogan Please confirm if the given descriptions about different modes in this documentation are correct or not? I made changes as per this documentations definitions for all the modes.
gkorland commentedon Sep 25, 2023
Origin comment by: @LiorKogan
Reference implementation for HalfDown, HalfEven, and AwayFromZero rounding:
gkorland commentedon Sep 25, 2023
Origin comment by: @LiorKogan
@Khalid6468
I think there are some problems with their convention. Their naming makes sense only for positive numbers.
They also have a bug with HALF_DOWN and negative x.5 numbers.
I would suggest the following:
Keep compatibility with
CEILINGHALF_DOWNHALF_EVENHALF_UPbut the following are simply wrong:
TOWARD_ZEROAWAY_FROM_ZEROgkorland commentedon Sep 25, 2023
Origin comment by: @Khalid6468
Okay. Thanks for confirming.
gkorland commentedon Sep 25, 2023
Origin comment by: @Khalid6468
@LiorKogan Done with the implementation. Please have a look at the PR #2668. Here are the sample outputs for the round function:
127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.14)"1) 1) "round(3.14)"2) 1) 1) "3"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.14653, 3)"1) 1) "round(3.14653, 3)"2) 1) 1) "3.147"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1465, 3, 'HALF_UP')"1) 1) "round(3.1465, 3, 'HALF_UP')"2) 1) 1) "3.147"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1465, 3, 'HALF_DOWN')"1) 1) "round(3.1465, 3, 'HALF_DOWN')"2) 1) 1) "3.146"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1465, 3, 'HALF_EVEN')"1) 1) "round(3.1465, 3, 'HALF_EVEN')"2) 1) 1) "3.146"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1365, 3, 'HALF_EVEN')"1) 1) "round(3.1365, 3, 'HALF_EVEN')"2) 1) 1) "3.136"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1355, 3, 'HALF_EVEN')"1) 1) "round(3.1355, 3, 'HALF_EVEN')"2) 1) 1) "3.136"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1351, 3, 'CEILING')"1) 1) "round(3.1351, 3, 'CEILING')"2) 1) 1) "3.136"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1359, 3, 'CEILING')"1) 1) "round(3.1359, 3, 'CEILING')"2) 1) 1) "3.136"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1359, 3, 'FLOOR')"1) 1) "round(3.1359, 3, 'FLOOR')"2) 1) 1) "3.135"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1351, 3, 'FLOOR')"1) 1) "round(3.1351, 3, 'FLOOR')"2) 1) 1) "3.135"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1351, 3, 'AWAY_FROM_ZERO')"1) 1) "round(3.1351, 3, 'AWAY_FROM_ZERO')"2) 1) 1) "3.136"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(3.1351, 3, 'TOWARD_ZERO')"1) 1) "round(3.1351, 3, 'TOWARD_ZERO')"2) 1) 1) "3.135"127.0.0.1:6379> GRAPH.QUERY social "RETURN round(0.0, 3, 'TOWARD_ZERO')"1) 1) "round(0.0, 3, 'TOWARD_ZERO')"2) 1) 1) "0"gkorland commentedon Sep 25, 2023
Origin comment by: @LiorKogan
@Khalid6468 thank you. We'll review.
Please make sure there are tests specifically for -1.5, -0.5, 0.5, and 1.5.
Also for NaN, -INF, +INF, and large inputs (e.g., 1.7E308).