...
Using floating-point loop counters can lead to unexpected behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
NUM09-J | Low | Probable | Low | P6 | L2 |
Automated Detection
Automated detection of floating-point loop counters is straightforward.
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| PMD.Basic.DontUseFloatTypeForLoopIndices | Don't use float type for loop indices | ||||||
Parasoft Jtest |
|
|
| PB-NUM-FPLI |
Do not use floating point variables as loop indices |
Related Guidelines
FLP30-C. Do not use floating-point variables as loop counters | |
Floating-point Arithmetic [PLF] |
Bibliography
...
...