Math.exp on the win_x86-32 jdk11 or later builds is returning 0.0 rather than Infinity. StrictMath.exp returns Infinity as expected.
public class MathTest {
public static void main(String[] args) {
System.out.println("StrictMath.exp(18232155.3323566D) = " + StrictMath.exp(18232155.3323566D));
System.out.println("Math.exp(18232155.3323566D) = " + Math.exp(18232155.3323566D));
System.out.println("StrictMath.exp(Double.MAX_VALUE / 500) = " + StrictMath.exp(Double.MAX_VALUE / 500));
System.out.println("Math.exp(Double.MAX_VALUE / 500) = " + Math.exp(Double.MAX_VALUE / 500));
System.out.println("StrictMath.exp(Double.MAX_VALUE / 200) = " + StrictMath.exp(Double.MAX_VALUE / 200));
System.out.println("Math.exp(Double.MAX_VALUE / 200) = " + Math.exp(Double.MAX_VALUE / 200));
System.out.println("StrictMath.exp(Double.MAX_VALUE) = " + StrictMath.exp(Double.MAX_VALUE));
System.out.println("Math.exp(Double.MAX_VALUE) = " + Math.exp(Double.MAX_VALUE));
System.out.println("StrictMath.exp(Double.MAX_VALUE + 1) = " + StrictMath.exp(Double.MAX_VALUE + 1));
System.out.println("Math.exp(Double.MAX_VALUE + 1) = " + Math.exp(Double.MAX_VALUE + 1));
}
}
>C:\openjdkjava\win_x86-32\jdk-11.0.9.1+1\bin\java -cp . MathTest
StrictMath.exp(18232155.3323566D) = Infinity
Math.exp(18232155.3323566D) = 0.0
StrictMath.exp(Double.MAX_VALUE / 500) = Infinity
Math.exp(Double.MAX_VALUE / 500) = 0.0
StrictMath.exp(Double.MAX_VALUE / 200) = Infinity
Math.exp(Double.MAX_VALUE / 200) = 0.0
StrictMath.exp(Double.MAX_VALUE) = Infinity
Math.exp(Double.MAX_VALUE) = 0.0
StrictMath.exp(Double.MAX_VALUE + 1) = Infinity
Math.exp(Double.MAX_VALUE + 1) = 0.0
public class MathTest {
public static void main(String[] args) {
System.out.println("StrictMath.exp(18232155.3323566D) = " + StrictMath.exp(18232155.3323566D));
System.out.println("Math.exp(18232155.3323566D) = " + Math.exp(18232155.3323566D));
System.out.println("StrictMath.exp(Double.MAX_VALUE / 500) = " + StrictMath.exp(Double.MAX_VALUE / 500));
System.out.println("Math.exp(Double.MAX_VALUE / 500) = " + Math.exp(Double.MAX_VALUE / 500));
System.out.println("StrictMath.exp(Double.MAX_VALUE / 200) = " + StrictMath.exp(Double.MAX_VALUE / 200));
System.out.println("Math.exp(Double.MAX_VALUE / 200) = " + Math.exp(Double.MAX_VALUE / 200));
System.out.println("StrictMath.exp(Double.MAX_VALUE) = " + StrictMath.exp(Double.MAX_VALUE));
System.out.println("Math.exp(Double.MAX_VALUE) = " + Math.exp(Double.MAX_VALUE));
System.out.println("StrictMath.exp(Double.MAX_VALUE + 1) = " + StrictMath.exp(Double.MAX_VALUE + 1));
System.out.println("Math.exp(Double.MAX_VALUE + 1) = " + Math.exp(Double.MAX_VALUE + 1));
}
}
>C:\openjdkjava\win_x86-32\jdk-11.0.9.1+1\bin\java -cp . MathTest
StrictMath.exp(18232155.3323566D) = Infinity
Math.exp(18232155.3323566D) = 0.0
StrictMath.exp(Double.MAX_VALUE / 500) = Infinity
Math.exp(Double.MAX_VALUE / 500) = 0.0
StrictMath.exp(Double.MAX_VALUE / 200) = Infinity
Math.exp(Double.MAX_VALUE / 200) = 0.0
StrictMath.exp(Double.MAX_VALUE) = Infinity
Math.exp(Double.MAX_VALUE) = 0.0
StrictMath.exp(Double.MAX_VALUE + 1) = Infinity
Math.exp(Double.MAX_VALUE + 1) = 0.0
- duplicates
-
JDK-8255368 Math.exp() gives wrong result for large values on x86 32-bit platforms
- Resolved