Closed triallax closed 2 years ago
See e.g. https://en.wikipedia.org/wiki/Sign_function. I think PureScript is pretty much unique in believing that signum 0 = 1.
How would you feel about changing the implementation to:
signum x =
if x < zero then negate one
else if x > zero then one
else x
I.e., returning x
if x
equals zero
rather than returning zero
. In any sane instance of Ring
this would be the same but Number
instantiates Ring
and has two zero-like values: +0.0 and -0.0. The Javascript implementation of Math.sign
makes this distinction and I think it would be nice to have signum
and sign
work the same way on Number
.
In fact, perhaps we should implement this new function as sign
and depreciate signum
.
@JamieBallingall That implementation is what I have in #280.
So I asked about this on the Slack channel, and @hdgarrood said that this was probably an oversight and that he thinks this should be fixed, based on the assumption that the function is not widely used, as this question was not asked before as far as he is aware.