-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: tb29552 Date: 03/17/99
/*
For x larger than 1.0e18, Math.sin(x) returns x rather than
the sin(x). Math.cos(x) has the same problem.
Interestingly, if the loop is removed the first statement
(before the loop) computes the correct value for sin(x), but
as is it computes 1e50 for the sin(1e50). This leads me to
think that the problem may be due to special code to handle
Math.sin in the JIT.
Note that the x86 harware instructions FSIN and FCOS are
only correct for |x| < 2^63 = 9.2e18. It looks like the JVM
or the JIT is using the hardware FSIN when there is a loop
and not doing the required range reduction for large x.
java full version "JDK-1.2-V"
Here is a sample code.
*/
public class largeXBug {
public static void main(String argv[]) {
System.out.println("x=1e50 sin(1e50)=" + Math.sin(1e50));
int n = 100;
for (int k = 0; k < n; k++) {
double x = Math.pow(10.0, k);
System.out.println("x=" + x + "\tsin(x)=" + Math.sin(x));
}
}
}
(Review ID: 55719)
======================================================================