The
IEEE standard
IEEE 754 specifies a standard method for both floating-point calculations and storage of floating-point values in various formats, including single (32-bit, used in Java's float) or double (64-bit, used in Java's double) precision. Some hardware also provides
extended precision formats that provide higher precision and/or a larger exponent range. On such architectures, it may be more efficient to compute intermediate results using such extended formats. This may avoid
round-off errors,
overflows and
underflows that would otherwise occur, but can cause programs to produce different output on such architectures. It was particularly expensive to avoid the use of extended precision on x86 machines with the traditional
x87 floating-point architecture. Although it was easy to control calculation precision, limiting the exponent range for intermediate results required additional costly instructions. Before JVM 1.2, floating-point calculations were required to be strict; that is, all intermediate floating-point results were required to behave as if represented using IEEE single or double precisions. This made it expensive on common x87-based hardware to ensure that overflows would occur where required. Starting with JVM 1.2, intermediate computations were, by default, allowed to exceed the standard exponent ranges associated with IEEE 32-bit and 64 bit formats. They were permitted to instead be represented as a member of the "extended-exponent" value set. On platforms like x87, overflows and underflows might not occur where expected, producing possibly more meaningful, but less repeatable, results instead. Since x87 floating point is no longer necessary on x86 processors supporting
SSE2, Java 17 again made all floating-point operations strict, effectively restoring the pre-1.2 semantics. == How it works ==