The Java language allows platforms to use available floating-point hardware that can provide /extended floating-point support/ with exponents that contain more bits than the standard Java primitive type double
(in the absence of the strictfp
modifier). Consequently, these platforms can represent a superset of the values that can be represented by the standard floating-point types. Floating-point computations on such platforms can produce different results than would be obtained if the floating-point computations were restricted to the standard representations of float
and double
. According to the Java Language Specification (JLS), §15.4, "FP-strict Expressions":
...
Using the strictfp
modifier leaves execution unchanged on platforms that lack platform-specific, extended floating-point behaviorsupport. It can have substantial impact, however, on both the efficiency and the result values of floating-point computations when executing on platforms that implement platform-specific provide extended floating-point behaviorsupport. On these platforms, using the strictfp
modifier increases the likelihood that intermediate operations will overflow or underflow because it restricts the range that can be represented and the precision of intermediate values; it can also reduce computational efficiency. These issues are unavoidable when portability is the main concern.
...
Noncompliant Code Example
On platforms whose Some platforms provide extended floating-point support in which their native floating-point hardware provides greater precision than double
. On these platforms, the JIT is permitted to use floating-point registers to hold values of type float
or type double
(in the absence of the strictfp
modifier), even though the registers support values with greater exponent range than that of the primitive types. Consequently, conversion from float
to double
can cause an effective loss of magnitude.
...
Failure to use the strictfp
modifier can result in nonportable, implementation-defined behavior with respect to the behavior of floating-point operations.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="7f62b02e87adc7fb-9b6434cf-44504625-bb01bac5-977fcecbfa143025606db14d"><ac:plain-text-body><![CDATA[ | [[Darwin 2004 | AA. Bibliography#Darwin 04]] | Ensuring the Accuracy of Floating-Point Numbers | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="24bed84bc7542205-442857b8-419b4968-ae2ca74f-1c2db246a9b316383ae7de6f"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§15.4, "FP-strict Expressions" | http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.4] | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d969bbf0883c1a93-45a21e73-439146e5-b76f93b0-cddb80608bf1dbda061ccdbc"><ac:plain-text-body><![CDATA[ | [[JPL 2006 | AA. Bibliography#JPL 06]] | 9.1.3. Strict and Non-Strict Floating-Point Arithmetic | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="509ff3671b7f4e70-d294a80e-459d4a57-8389bef2-e24dda84166c8e5ecf906769"><ac:plain-text-body><![CDATA[ | [[McCluskey 2001 | AA. Bibliography#McCluskey 01]] | Making Deep Copies of Objects, Using strictfp, and Optimizing String Performance | ]]></ac:plain-text-body></ac:structured-macro> |
...