Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When precise computation is necessary, such as when performing currency calculations, then floating-point types must not be used. Instead, use an alternative representation that can completely represent the necessary values.

...

Because the value 0.10 lacks an exact representation in either Java floating-point type (or any floating-point format that uses a binary mantissa), on most platforms, this program prints:

Code Block
A dollar less 7 dimes is $0.29999999999999993

...

The CERT C Secure Coding Standard

FLP02-C. Avoid using floating point numbers when precise computation is needed

The CERT C++ Secure Coding Standard

FLP02-CPP. Avoid using floating point numbers when precise computation is needed

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b47a357bd6267435-266aa04b-48d9438e-89c28af7-c0e1dd72ebbed80cf1081bf5"><ac:plain-text-body><![CDATA[

[ISO/IEC TR 24772:2010

http://www.aitcnet.org/isai/]

Floating-Point Arithmetic [PLF]

]]></ac:plain-text-body></ac:structured-macro>

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e1f06396002d0b51-7b8c3674-4a0c4d8b-96eebf23-4ea1ebe328d99179e3674799"><ac:plain-text-body><![CDATA[

[[Bloch 2008

AA. Bibliography#Bloch 08]]

Item 48, Avoid float and double if exact answers are required

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="85d4a2613780ed91-68239919-47b345b8-9833912f-d8598d91eca2bcfe4e3923b0"><ac:plain-text-body><![CDATA[

[[Bloch 2005

AA. Bibliography#Bloch 05]]

Puzzle 2, Time for a change

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="43fc7129715d7f3e-7bc2cd44-4bb641eb-a57aaba1-059964bd4694c5a30bcfd616"><ac:plain-text-body><![CDATA[

[[Goldberg 1991

AA. Bibliography#Goldberg 91]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3b96aeeb1f58183f-b7596a9c-4be14c41-88398250-755e75def61f0bf5078c00b1"><ac:plain-text-body><![CDATA[

[[IEEE 754

AA. Bibliography#IEEE 754 2006]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="aa1974a0c3af9d39-ebe19696-4ecb42c3-b014bd9a-4787ec8e5d3c30db4919546e"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

[§4.2.3, Floating-Point Types, Formats, and Values

http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3]

]]></ac:plain-text-body></ac:structured-macro>

...