...
It is acceptable to perform operations using a mix of integer and floating-point values when deliberately exploiting the properties of integer arithmetic before conversion to floating point. For example, use of integer arithmetic eliminates the need to use the floor()
method. Any such code must be clearly documented to help future maintainers understand that this behavior is intentional.
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Parasoft Jtest |
| CERT.NUM50.IDCD | Do not assign the result of an integer division to a floating point variable | ||||||
SonarQube |
| S2184 |
Bibliography
...
...