Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider Java v3.0

...

Code Block
bgColor#FFCCCC
for (float x = 0.1f; x <&lt;= 1.0f; x += 0.1f) {
  // ... 
}

...

Code Block
bgColor#ccccff
for (int count = 1; count <&lt;= 10; count += 1) {
  float x = count/10.0f;
  // ...
}

...

Code Block
bgColor#FFCCCC
for (float x = 100000001.0f; x <&lt;= 100000010.0f; x += 1.0f) {
  /* ... */
}

...

Code Block
bgColor#ccccff
for (int count = 1; count <&lt;= 10; count += 1) {
  double x = 100000000.0 + count;
  /* ... */
}

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Other Languages

This rule appears in the C Secure Coding Standard as FLP30-C. Do not use floating point variables as loop counters.

...

FLP04-J. Check floating point inputs for exceptional values      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;07. Floating Point (FLP)      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FLP31-J. Convert integers to floating point for floating point operations