-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Denormalized result of certain double values multiplication is rounded incorrectly.
In the example below the production's mantissa has bits to be rounded of "01111" form -
near half ulp, but not equals. But the result is rounded to upper representable value.
The bug appears on win32 platform for JDK 1.1 through 1.2beta4 and 12fcsE
with and without Symantec jit.
The bug causes failure of the JCK test tests/lang/FP/fpl038/fpl03804m2/fpl03804m2.html
--------------------------------------- Dmul.java
import java.io.PrintStream;
class Dmul {
static final long ONE = 1;
public static void main(String[] argv) {
if (!testMul(System.out))
System.out.println(" Passed" );
}
static strictfp boolean testMul( PrintStream out) {
double Y,X,U;
X = 0.78125;
Y = 2.225073858507205E-308;
U = 1.7383389519587536E-308;
if ( X * Y != U ) {
final long twoM = ONE << 53;
double diff2m = (X * Y * twoM) - (U * twoM);
out.println(" Diff*2m is " +diff2m +" for " +X +" * " +Y +" from waited " +U);
out.println(" diff2m=" +show(diff2m) +" , X=" +show(X) +" , Y=" +show(Y)
+" , U=" +show(U) );
return true;
}
return false;
}
static String show( double r ) {
return "0x"+Long.toHexString(Double.doubleToLongBits(r));
}
}
--------------------------------------- log
D:\users\inev>H:\ld14\java\dest\jdk1.2b4K\win32\bin\java Dmul
Diff*2m is 4.450147717014403E-308 for 0.78125 * 2.225073858507205E-308 from waited 1.7383389519587536E-308
diff2m=0x20000000000000 , X=0x3fe9000000000000 , Y=0x10000000000007 , U=0xc800000000005
In the example below the production's mantissa has bits to be rounded of "01111" form -
near half ulp, but not equals. But the result is rounded to upper representable value.
The bug appears on win32 platform for JDK 1.1 through 1.2beta4 and 12fcsE
with and without Symantec jit.
The bug causes failure of the JCK test tests/lang/FP/fpl038/fpl03804m2/fpl03804m2.html
--------------------------------------- Dmul.java
import java.io.PrintStream;
class Dmul {
static final long ONE = 1;
public static void main(String[] argv) {
if (!testMul(System.out))
System.out.println(" Passed" );
}
static strictfp boolean testMul( PrintStream out) {
double Y,X,U;
X = 0.78125;
Y = 2.225073858507205E-308;
U = 1.7383389519587536E-308;
if ( X * Y != U ) {
final long twoM = ONE << 53;
double diff2m = (X * Y * twoM) - (U * twoM);
out.println(" Diff*2m is " +diff2m +" for " +X +" * " +Y +" from waited " +U);
out.println(" diff2m=" +show(diff2m) +" , X=" +show(X) +" , Y=" +show(Y)
+" , U=" +show(U) );
return true;
}
return false;
}
static String show( double r ) {
return "0x"+Long.toHexString(Double.doubleToLongBits(r));
}
}
--------------------------------------- log
D:\users\inev>H:\ld14\java\dest\jdk1.2b4K\win32\bin\java Dmul
Diff*2m is 4.450147717014403E-308 for 0.78125 * 2.225073858507205E-308 from waited 1.7383389519587536E-308
diff2m=0x20000000000000 , X=0x3fe9000000000000 , Y=0x10000000000007 , U=0xc800000000005