JDK 9 RFR of JDK-8134795: Port fdlibm pow to Java

Jeff Hain jeffhain at rocketmail.com
Thu Sep 17 22:12:57 UTC 2015


>At long last, I've started the port of the C version of FDLIBM (freely
>distributable math library) from C to Java, beginning with the pow method:

I ran it through tests of my math lib (jafama),
and found the following issue:

// ok
    StrictMath.pow(1.0000000000000004, 2.1E9) = 1.0000009325877754
FdLibm.Pow.compute(1.0000000000000004, 2.1E9) = 1.0000009325877754

// overflows early
    StrictMath.pow(1.0000000000000004, 2.2E9) = 1.0000009769967388
FdLibm.Pow.compute(1.0000000000000004, 2.2E9) = Infinity

// actual overflow is much further
    StrictMath.pow(1.0000000000000004, 1.59828858065033216E18) = 1.7976931348621944E308
    StrictMath.pow(1.0000000000000004, 1.59828858065033242E18) = Infinity

Comparing the behavior of your code with that of Eric Blake's StrictMath
(the version I got has other issues, but not that one),
it could be corrected by replacing

if (x_abs > 1.0) {


if (x_abs >= 1.0000009536743164) {

After that modification, tests didn't show any difference with StrictMath.


More information about the core-libs-dev mailing list