Closed bit-app-3000 closed 9 months ago
Thank you @bit-app-3000 - I'm aware of this, but this warning can be ignored in this case, since the full line here reads:
if (x === -0) x = 0;
So regardless if 0
or -0
, I want both cases to be 0
.
In fact, this line could/should be written as an early bail out:
if (x === -0) return 0;
maybe it will be more convenient?
if ( !Math.abs(x) ) return 0;
[DEBUG] Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero]
Floating-point equality is defined such that 0 and -0 are equal, so "x === -0" returns true for both 0 and -0. You need to use "Object.is(x, -0)" instead to test for -0.