nthRoot function
Converts x
to a double and returns the positive nth
root of the
value.
Returns -0.0 if x
is -0.0, and NaN if x
is otherwise negative or NaN.
Implementation
double nthRoot(num nth, num x) {
if (nth == 2) return sqrt(x);
num ret = pow(x, 1 / nth);
if (ret is double) return ret;
return ret.toDouble();
}