...
Code Block | ||
---|---|---|
| ||
strictfp class Example { double d = 0.0; public void example() { float f = Float.MAX_VALUE; float g = Float.MAX_VALUE; this.d = f * g; System.out.println("d (" + this.d + ") might not be equal to " + (f * g)); } public static void main(String[] args) { Example ex = new Example(); ex.example(); } } |
Exceptions
NUM06-EX1EX0: This rule applies only to calculations that require consistent floating-point results on all platforms. Applications that lack this requirement need not comply.
NUM06-EX2EX1: The strictfp
modifier may be omitted when competent numerical analysis demonstrates that the computed values will meet all accuracy and behavioral requirements that are appropriate to the application. Note that "competent numerical analysis" generally requires a specialized professional numerical analyst; lesser levels of rigor fail to qualify for this exception.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="12fe4038af0d9980-cf3ccfb6-40e84366-a1d6b911-ca36ad78a44adcdc639a5218"><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="1c1160e1334190a6-71a3821f-46ac4537-98adb653-45542ccbc0b8fd8e722554e9"><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="50eee11d75250b69-4ee274b5-4c2746ac-81eab613-ce38af9c3a70d659d361f29c"><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="d94ed5d5390ce90a-23550903-40594363-a552a8f4-1b9ac3677fb9c9aaeeae6e22"><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> |
...