Articles
Java Platform, Standard Edition
SYNOPSIS:
Floating point multiplication is imprecise when the product has many significant digits.
FULL PRODUCT VERSION:
java version "1.5.0_06"
Java™ 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot™ Client VM (build 1.5.0_06-b05, mixed mode, sharing)
FULL OS VERSION:
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM:
Multiplying two doubles resulted in an imprecise product. The virtual machine dropped the last significant digit when the product had many significant digits.
SOURCE CODE FOR TEST CASE:
public class Test {
public static void main(String[] args) {
double x = 2.0;
double y = 2.00000000000000000001;
System.out.println("x * y = " + (x*y));
}
}
STEPS TO REPRODUCE:
EXPECTED BEHAVIOR:
x * y = 4.00000000000000000002
ACTUAL BEHAVIOR:
x * y = 4.0
REPRODUCIBILITY:
This bug can be reproduced always.
| Copyright 1994-2006 Sun Microsystems, Inc. | |