Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

...

Code Block
bgColor#ccccff
strictfp class Example {
  public static void main(String[] args) {
    double d = Double.MAX_VALUE;
    System.out.println("This value \"" + ((d * 1.1d) / 1.1d) + "\" cannot be represented as double.");
  }
}

Note that this This compliant solution also specifies that the floating-point literals (1.1) are of type double to clarify their expected type ; this complies with rule "NUM18-J. Be aware of numeric promotion behavior."and minimize their lack of precision.

Noncompliant Code Example

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f3809fdd58a2cda9-de86eb2b-49ad4dbd-91159b17-963d26df6fe2e3904da09f0e"><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="cd7f9cc176ab4dd3-4c9981d6-44dd4f8f-bcc09da5-71d4a00edaad0a727276fcf0"><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="091dd9fe18efeee1-80690ee2-41744c1f-ad008fb2-a5bbd803b7e5266e33967f2c"><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="152169b50780cbf8-1d6c7143-404f4e75-90719653-86f6e7599c8da3ab803367ac"><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>

...