...
In addition, because floating-point numbers can represent large values, programmers often mistakenly assume that they can represent all digits of those values. To gain a large dynamic range, floating-point numbers maintain a fixed number of bits of precision and an exponent. Incrementing a large floating-point value may might not change that value within the available precision. Consequently, floating-point variables should not be used as loop counters.
...
Search for vulnerabilities resulting from the violation of this guideline on the CERT website.
Other Languages
Related Guidelines
This guideline appears in the C Secure Coding Standard as : FLP30-C. Do not use floating point variables as loop counters.This guideline appears in
the C++ Secure Coding Standard as : FLP30-CPP. Do not use floating point variables as loop counters.
Bibliography
Wiki Markup |
---|
\[[Bloch 2005|AA. Bibliography#Bloch 05]\] Puzzle 34: Down for the Count \[[JLS 2005|AA. Bibliography#JLS 05]\] [Section 4.2.3, Floating-Point Types, Formats, and Values|http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3] |
...