JDK-8046060 : Different results of floating point multiplication for lambda code block
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86
  • Submitted: 2014-06-05
  • Updated: 2015-01-21
  • Resolved: 2014-06-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40 b01Fixed 9Fixed
Description
The result of execution of floating point expression invoked in the lambda code block is different:

2.1552676198089365E-308
2.155267619808936E-308

strictfp
public class type04404 {

    public static void main(String args[]) {
        clone(() -> {
            double x = Double.longBitsToDouble(0x1e7ee00000000000L);
            double y = Double.longBitsToDouble(0x2180101010101010L);

            double z = x * y;
            System.out.println(z);
        });
        {
            double x = Double.longBitsToDouble(0x1e7ee00000000000L);
            double y = Double.longBitsToDouble(0x2180101010101010L);

            double z = x * y;
            System.out.println(z);
        }
    } 
 
    private static void clone(Face arg) {
        arg.run();
    }

    private interface Face {
        void run();
    }
}
Comments
jdk8u-dev now collecting 8u40 fixes
23-06-2014

Robert, correct that's what I meant
17-06-2014

Vicente, I assume you are meaning the strict flag should be propagated from the class (rather than always on)
16-06-2014

IMO the method implementing the lambda should have the ACC_STRICT flag
05-06-2014