Why is this an issue?

Double.longBitsToDouble converts the bit pattern into its corresponding floating-point representation. The method expects a 64-bit long argument to interpret the bits as a double value correctly.

When the argument is a smaller data type, the cast to long may lead to a different value than expected due to the interpretation of the most significant bit, which, in turn, results in Double.longBitsToDouble returning an incorrect value.

Noncompliant code example

int i = 0x80003800;
Double.longBitsToDouble(i);   // Noncompliant - NaN

Compliant solution

long i = 0x80003800L;
Double.longBitsToDouble(i);   // Compliant - 1.0610049784E-314

Resources

Documentation

Articles & blog posts