...
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 |
---|
PMD.Basic.DontUseFloatTypeForLoopIndices
Parasoft Jtest |
| CERT.NUM09.FPLI | Do not use floating point variables as loop indices | ||||||
PVS-Studio |
| V6108 |
Related Guidelines
FLP30-C. Do not use floating-point variables as loop counters | |
ISO/IEC TR 24772:2010 | Floating-point Arithmetic [PLF] |
Bibliography
...
...