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
(Note that a similar construction in hexadecimal literals, (f32.const +0x1.00000100000000001p-50), correctly rounds to 0x1.000002p-50.)
The value in question is almost in the middle of two consecutive binary32 fp number 0x1.0p-50 and 0x1.000002p-50, but it is not the exact middle and in fact very slightly closer to 0x1.000002p-50:
The root cause is the inaccuracy of fxx.ml line 285. String.length s here is 25 (20 significant digits + . + e-16), so the format string is %.25g, but %g is platform-dependent! (source) In my experience, msvcrt's printf notably does not give any more significant digits than the type's own limit (even %.100f gives ~18 significant digits followed by zeroes), so %.25g actually doesn't make any difference with msvcrt. The correct approach would be to use an actual bigint (scaled by, say, 5^1100 to elide fractional digits).
Interesting. Oh well. The best fix would probably be to either implement custom parsing and/or rounding, or call strtof through the FFI. But given that this is such a niche problem, and does not seem to affect the current test suite, I'm not sure who'd volunteer.
Activity
Fix incorrectly generated const.bin.wast. (WebAssembly/spec#2150)
rossberg commentedon Apr 23, 2026
Interesting. Oh well. The best fix would probably be to either implement custom parsing and/or rounding, or call strtof through the FFI. But given that this is such a niche problem, and does not seem to affect the current test suite, I'm not sure who'd volunteer.
[-]Double rounding fix is (still) wrong in Windows[/-][+]Double rounding fix is (still) insufficient[/+]rossberg commentedon Oct 21, 2026
This also seems to affect non-Windows platforms in some cases, see #2282.