...
Code Block | ||
---|---|---|
| ||
for (float x = 0.1f; x <<= 1.0f; x += 0.1f) { // ... } |
...
Code Block | ||
---|---|---|
| ||
for (int count = 1; count <<= 10; count += 1) { float x = count/10.0f; // ... } |
...
Code Block | ||
---|---|---|
| ||
for (float x = 100000001.0f; x <<= 100000010.0f; x += 1.0f) { /* ... */ } |
...
Code Block | ||
---|---|---|
| ||
for (int count = 1; count <<= 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 07. Floating Point (FLP) FLP31-J. Convert integers to floating point for floating point operations