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

[interpreter] rounding for floating-point constants #809

Closed
sunfishcode opened this issue May 23, 2018 · 3 comments · Fixed by #1025
Closed

[interpreter] rounding for floating-point constants #809

sunfishcode opened this issue May 23, 2018 · 3 comments · Fixed by #1025
Labels
interpreter issues that only affect the interpreter

Comments

@sunfishcode
Copy link
Member

The interpreter currently rejects (f32.const 0x1.fffffefffffff8000000p127), because it rounds the value up, out of the finite range of f32. Ideally, floating-point literals should be interpreter as if they were floating-point values with infinite precision, and then rounded in a single step to the expression type.

See also the background discussion here.

@ericprud
Copy link

@sunfishcode, does the above merge close this issue?

@binji
Copy link
Member

binji commented May 22, 2019

@ericprud No, this issue was added as a result of discussion on that PR. It's still a problem, but it's a minor one as it only affects how some floats are interpreted in the text format when given extra precision.

It's perhaps not even an issue with the spec, but with the reference interpreter (and other tools). The spec clearly says that the value should be treated as infinite precision then rounded to the nearest (non-infinite) value, see http://webassembly.github.io/spec/core/text/values.html#floating-point.

@binji binji added the interpreter issues that only affect the interpreter label May 22, 2019
rossberg added a commit that referenced this issue May 27, 2019
@rossberg
Copy link
Member

Parsing float literals via f64 exhibits a double rounding issue similar to the one from #421. Incorrect rounding to infinity is just one case.

#1025 adds various test cases, plus a gross hack to the interpreter to correct double rounding errors when parsing small floats (unfortunately, we cannot use a fix as simple as in #1021). PTAL

satabin added a commit to satabin/swam that referenced this issue Jun 15, 2019
This fixes issue reported here WebAssembly/spec#809
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter issues that only affect the interpreter
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants