Name: boT120536 Date: 09/04/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build Blackdown-1.3.0-RC1)
Java HotSpot(TM) Client VM (build Blackdown-1.3.0-RC1, mixed mode)
I suggest you add the method kthRoot to the class java.lang.Math.
Currently there is a sqrt function for the square root. Another user
has submitted a request for cubeRoot for the cube root. I propose
kthRoot for the kth root.
Of course, people can use pow(a, 1/k) for the same effect. However,
if a is a negative number, this returns NaN, even if k is odd. And it
is not easy to extend the pow function to handle this correctly because
the floating point numbers are only approximations of the fractions.
Here are illustrations of the problem.
I want to compute the cube root of -27.
If I use pow(-27, 1/3) the result is NaN (instead of the desired -3).
I want to compute the fifth root of -32.
If I use pow(-32, 1/5) the result is NaN (instead of the desired -2).
(Review ID: 131190)
======================================================================