Closed kripken closed 9 years ago
d'oh, thanks!
I forgot to ask: could you add a test case?
Hmm, I actually can't - when I try to write a test here, it passes even without my fix. Any idea why that might happen?
Perhaps it parses -0.
into a unary and a number, in this repo but not in emscripten, but that seems very puzzling. But it never hits the "is negative" code path in your repo, yet the test passes. Maybe I don't understand what "pass" means here.
Ah, then this could be a bug in emscripten_print_double. This would make sense since once would expect snprintf() to correctly print -0.
Hmm, it literally just calls the JS printing code, and it's also used in the emscripten test suite when using the polyfill, but it behaves as expected there. Very strange. Anyhow, it's covered by tests in emscripten.
Negative zero is a never-ending source of "fun". This fixes printing of them in the polyfill.
(Casting to a float is an optimization for emscripten; otherwise, to get the 64 bits of the double, it uses two 32-bit values and does some more pointless work.)