tc39 / eshost

A uniform wrapper around a multitude of ECMAScript hosts. CLI: https://github.com/bterlson/eshost-cli
Other
142 stars 36 forks source link

Handling negative zero in print function #75

Closed chicoxyzzy closed 5 years ago

chicoxyzzy commented 5 years ago
➜ eshost -itsx 'print(-0)'
## Source
print(-0)

┌─────┬───┐
│ ch  │ 0 │
│ jsc │   │
│ sm  │   │
│ v8  │   │
│ xs  │   │
└─────┴───┘

In fact result should be -0 (as it happens in all browser consoles), but -0 coerces to String somewhere. Probably this should be special-cased.

rwaldron commented 5 years ago

This isn't a bug in eshost:

$ jsc
>>> -0
0
>>> print(-0)
0
undefined
>>>

$ sm
js> -0
-0
js> print(-0)
0
js>

$ v8
V8 version 7.5.45
d8> -0
0
d8> print(-0)
0
undefined
chicoxyzzy commented 5 years ago

Oh I didn't know print is integrated into js shells (along with read, load and possibly others)