...
Using floating-point representations when precise computation is required can result in a loss of precision and incorrect values.
Rule | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
NUM04-J | Low | Probable | No | NoHigh | P2 | L3 |
Automated Detection
Automated detection of floating-point arithmetic is straightforward. However, determining which code suffers from insufficient precision is not feasible in the general case. Heuristic checks, such as flagging floating-point literals that cannot be represented precisely, could be useful.
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Parasoft Jtest |
| PBCERT.NUMNUM04.UBD | Do not use "float" and "double" if exact answers are required |
...
...