Replying to the four proposals you sent in one mail for easier discussion:

OK.  I've replied to your replies in this thread as 4 short posts.

*** Rename Math.sign to Math.signum ***
There isn't overwhelming precedent in either direction here.  Java and
Matlab are signum, .NET and Python (numpy) and Mathematica are sign.  C
has a different but related copysign.  To the extent there is precedent,
it seems slightly in favor of 'sign', and it's slightly less cryptic.

The sign function complements the abs (magnitude) function.  (copySign is an
invention of IEEE754, which also has copyAbs - these are explicit in the
face of IEEE "signaling NaNs".)

Clearly the word "sign" has meaning on the Real line, but think of the
Complex plane where the range of the sign function is a circle of unit
magnitude (or a zero).  A complex number, z, in polar coordinates has a
magnitude/modulus/amplitude, r, and an argument/phase, theta; where r=abs(z)
and theta=sign[um](z).

Also, the so-called "sign" function returns information about the magnitude
as well as the +/- sign when the magnitude is a 0:
     Math.sign[um](-0)==-0
     Math.sign[um](0)==0.

This is pretty vague, but the word "signum" just feels to me better than
"sign", in the light of the above.

Here is an implementation that works with +0 and -0 and NaN ...

   Math.signum = function(x) { return (x>0)? 1 : (x<0)? -1 : x; }


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to