lukewagner / polyfill-prototype-1

Experimental WebAssembly polyfill library and tools
Apache License 2.0
241 stars 42 forks source link

Handle negative zero #12

Closed kripken closed 9 years ago

kripken commented 9 years ago

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.)

lukewagner commented 9 years ago

d'oh, thanks!

lukewagner commented 9 years ago

I forgot to ask: could you add a test case?

kripken commented 9 years ago

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?

kripken commented 9 years ago

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.

lukewagner commented 9 years ago

Ah, then this could be a bug in emscripten_print_double. This would make sense since once would expect snprintf() to correctly print -0.

kripken commented 9 years ago

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.