Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the rounding rule match the baseline #746

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

edorfaus
Copy link

In PR #392 a rule was added that rounding must be done by the IEEE 754 rule "towards positive infinity". This rule is also known as rounding up, or ceiling (it rounds 1.1 to 2).

However, the baseline implementation does not do this - instead, it rounds to nearest, with ties towards positive infinity.

The same PR adds an extra rounding step that I think improves the resilience against accumulated floating-point errors (by using knowledge about the input values), but does not actually change its rounding behavior otherwise.

I'm assuming that the current baseline behavior is intended, making the error be in the rule text (probably based on a simple misunderstanding of the standard). Therefore I propose a rule change to make the rules match the baseline implementation.

Since the other implementations are verified against the baseline output rather than directly against the rules, this avoids any need for code changes.

This PR also adds a few test cases to the rounding test, that I used to verify the expected rounding rules for both positive and negative numbers, without it being obscured by the floating-point inaccuracy. (Both the baseline and baseline_original_rounding implementations pass these tests, but code that uses any of the IEEE 754 rounding rules won't.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant