Nathan Wall (2013-10-30T15:13:36.000Z)
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. ;)

Nathan
domenic at domenicdenicola.com (2013-11-03T22:26:18.982Z)
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. ;)