A Math.cbrt cube root function would be nice.
This should be more accurate than pow(x,1/3) and should not have a domain
error for x<0.
Unlike pow():
Math.cbrt(-0) == -0
This confuses me. Math.pow(0, 1/3) === Math.pow(-0, 1/3) === 0.
Math.cbrt(-0) should most certainly also === 0, since -0 === 0. Was
this a typo?
No not a typo; it is the analytically correct handling of -0 in the symmetry
relation of an odd function.
(See http://en.wikipedia.org/wiki/Even_and_odd_functions).
Most people don't care about -0, and it is right that -0==0.
However -0 is important in Analysis:
1) it selects the side of a branch cut in the Complex plane (and likely
preserves symmetry),
2) modelling applications often require reflectional symmetry about an axis.
JavaScript already handles -0 well in mathematical functions (but not in
strings!):
Math.sin(-0) == -0
Strangely IEEE defines and JavaScript conforms:
Math.sqrt(-0) == -0
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss