RE: Math.sign vs ±0

Nathan Wall nathan.wall at
Wed Oct 30 08:13:36 PDT 2013

Nathan Wall wrote:
> At the very least, I think Oliver has a point in that it'd be very
> useful to have a sign function which would return 1 for +0 and -1
> for -0. I've needed this in the past. If it shouldn't be `Math.sign`,
> perhaps there should be a `Number.sign` which would match the other
> use-case (one that I think would be more useful for meta-programming
> than what we have for `Math.sign`).

On the other hand, it would probably confuse a lot of novice programmers who aren't familiar with IEEE 754 if sign(0) returned 1.  I could see that showing up in a list of JS WTFs. ;)


More information about the es-discuss mailing list