Skip to content

Conversation

@Lojjs
Copy link
Contributor

@Lojjs Lojjs commented Nov 23, 2022

We follow the behaviour of Java, i.e. rounding towards positive infinity for ties when we have no precision or mode or rounding according to https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/RoundingMode.html for rounding modes.

The current description was wrong in some cases and missleading in others. Also added more examples.

Fixes #neo4j/neo4j#12972 and neo4j/neo4j#12963

@Lojjs Lojjs added bug Something isn't working team-cypher-surface team-cypher-runtime 5.x Applies to all Neo4j 5 docs labels Nov 23, 2022
@neo-technology-commit-status-publisher
Copy link
Collaborator

Looks like you've updated the documentation!

Check out your changes at https://neo4j-docs-cypher-230.surge.sh

@Lojjs
Copy link
Contributor Author

Lojjs commented Nov 23, 2022

@Lojjs
Copy link
Contributor Author

Lojjs commented Nov 23, 2022

Copy link
Contributor

@nadja-muller nadja-muller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a great improvement! I left some remarks where I think we could do even better 😁

Copy link
Collaborator

@JPryce-Aklundh JPryce-Aklundh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I just have one question and one suggestion.

== round(), with precision

`round()` returns the value of the given number rounded with the specified precision, with half-values always being rounded up.
`round()` returns the value of the given number rounded to the closest value of given precision, with ties always being rounded away from zero (rounding mode `HALF_UP`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this instead read: (using rounding mode HALF_UP)
or
(the default rounding mode is HALF_UP)

*Considerations:*
|===

| For the rounding modes, a tie refers to that the two closest values of the given precision are on the same distance from the given value.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| For the rounding modes, a tie refers to that the two closest values of the given precision are on the same distance from the given value.
| For the rounding modes, a tie means that the two closest values of the given precision are at the same distance from the given value.

Lojjs added 4 commits December 8, 2022 15:09
We follow the behaviour of Java, i.e. rounding towards positive infinity for ties when we have no precision or mode or rounding according to https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/RoundingMode.html for rounding modes.

The current description was wrong in some cases and missleading in others. Also added more examples.
- Better description of round(x, precision)
- Better description of HALF_UP and HALF_DOWN
- Semantic order instead of alphabetical
@JPryce-Aklundh JPryce-Aklundh merged commit ae345d0 into neo4j:dev Dec 8, 2022
@JPryce-Aklundh JPryce-Aklundh deleted the dev-update-round-function-docs branch December 8, 2022 14:12
JPryce-Aklundh added a commit that referenced this pull request Dec 8, 2022
Original PR: #230

authored-by: Louise Söderström <louise.soderstrom@neo4j.com>
JPryce-Aklundh added a commit that referenced this pull request Dec 8, 2022
Original PR: #230

authored-by: Louise Söderström <louise.soderstrom@neo4j.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x Applies to all Neo4j 5 docs bug Something isn't working team-cypher-runtime team-cypher-surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants