https://bz.apache.org/bugzilla/show_bug.cgi?id=62121

## Advertising

--- Comment #6 from Axel Howind <a...@dua3.com> ---
(In reply to mewalig from comment #5)
I don't know if this should really be mimicked. But if so, the code should be
corrected in some places (still untested and should be checked if we really
want to do zhis):
we should only do a special treatment for negative x, so it should be
> if(x<0 && abs(y) < 1) {
Now you want to know if y is the reciprocal of an int. Lets call that r
(reciprocal) instead of one_over (that name made me think about "n over k"
instead and it took some time before I got the meaning).
We can use Math.rint() instead of Math.round() as the result is converted back
to int for the comparison anyway.
Also, the smallest value that still gives the correct result depends on the
values being compared. Without trying, I'd think 2 ulp (units in the last
place) should be a safe bet.
> // test if y is the reciprocal of an integer value
> double r = 1/y;
> double rInt = Math.rint(r);
> if(abs(r - rInt) < 2*Math.ulp(r)) {
At last the missing part:
> // find the yth root and return that (undefined for even rInt)
> return ((int)rInt)%2==0 ? Double.NAN : -Math.pow(-x,y);
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org