0
Fork 0
mirror of https://github.com/dop251/goja.git synced 2026-11-17 19:47:16 +00:00
goja/builtin_math_test.go
Spicy Shark a7bf910fa3
Return a Number from Math.sign when the argument converts to NaN or zero (#812)
* Return a Number from Math.sign when the argument converts to NaN or zero

Math.sign returned its argument itself for a NaN or zero result, so
Math.sign(null) was null, Math.sign("0") was "0" and Math.sign(undefined)
was undefined. ECMA-262 21.3.2.30 step 2 returns n, the Number from
ToNumber(x). Return the converted Number; floatToValue keeps -0.

* Use the pre-boxed values in Math.sign

Return _NaN, _negativeZero and _positiveZero for the NaN and zero results
instead of passing the number through floatToValue.
2026-10-20 14:02:21 +01:00

38 lines
1.5 KiB