...
When converting integers to floating-point values, and vice versa, it is important to carry out proper range checks to avoid undefined behavior. (See FLP34-C. Ensure that floating-point conversions are within range of the new type.)
Noncompliant Code Example
...
| CERT C++ Secure Coding Standard | FLP33-CPP. Convert integers to floating point for floating point operations |
| CERT Oracle Secure Coding Standard for Java | NUM50-JG60. Convert integers to floating-point for floating-point operations |
| MITRE CWE | CWE-681, Incorrect conversion between numeric types CWE-682, Incorrect calculation |
Bibliography
| [Hatton 1995] | Section 2.7.3, "Floating-Point Misbehavior" |