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 JLS, §15.4, "FP-strict Expressions" [JLS 2005]:
The net effect \ [of non-fp-strict evaluation\], roughly speaking, is that a calculation might produce "the correct answer" in situations where exclusive use of the float value set or double value set might result in overflow or underflow. Wiki Markup
Programs that require consistent results from floating-point operations across different JVMs and platforms must use the strictfp
modifier. This modifier requires the JVM and the platform to behave as though all floating-point computations were performed using values limited to those that can be represented by a standard Java float
or double
, guaranteeing that the result of the computations will match exactly across all JVMs and platforms.
...
FLP00-C. Understand the limitations of floating point numbers | |
FLP00-CPP. Understand the limitations of floating point numbers |
Bibliography
...
[[Darwin 2004AA. References#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="f1dbe0ce-1c8a-4437-b8c1-7546013b8228"><ac:plain-text-body><![CDATA[ | [[JLS 2005AA. References#JLS 05]] | 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="3580003c-741c-44d4-b4e0-f3e2d98193f7"><ac:plain-text-body><![CDATA[ | |
[[JPL 2006AA. References#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="fff9e068-7fd1-4b06-9481-278d9e28cb33"><ac:plain-text-body><![CDATA[ | [[McCluskey 2001AA. References#McCluskey 01]] | Making Deep Copies of Objects, Using strictfp, and Optimizing String Performance]]></ac:plain-text-body></ac:structured-macro> |
...
NUM05-J. Do not use denormalized numbers 03. Numeric Types and Operations (NUM)