...
Because 0.1f
is rounded to the nearest value that can be represented in the value set of the float
type, the actual quantity added to x
on each iteration is somewhat larger than 0.1
; consequently. Consequently, the loop executes only nine times and fails to produce the expected output.
...
FLP30-C. Do not use floating point variables as loop counters | ||||
FLP30-CPP. Do not use floating point variables as loop counters | ||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e2fff6cdbceb19f9-64316130-49a349df-8774ab1c-afc8e862999fc493f13bbd2d"><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="32f9a317673c3c15-8c573aae-4af44d04-8783820f-a7d07c0ccc0cfc5ff53f96ea"><ac:plain-text-body><![CDATA[ | [[Bloch 2005 | AA. Bibliography#Bloch 05]] | Puzzle 34: Down for the Count | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8faedd70c4bcad4c-0a57896b-464c4057-bebe9258-92c8b277d9f54a1803b9ae82"><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> |
...