There shall be no implicit floating-integral conversions
There shall be no implicit floating-integral conversions.
If you convert from a floating point to an integer type, you lose information. Unless you explicitly cast from floating point to an integer type, it is not clear whether the loss of information is intended. Additionally, if the floating-point value cannot be represented in the integer type, the behavior is undefined.
Conversion from an integer to floating-point type can result in an inexact representation of the value. The error from conversion can accumulate over later operations and lead to unexpected results.
The checker flags implicit conversions between floating-point types
(float and double) and integer types
(short, int, etc.).
This rule takes precedence over 5-0-4 and 5-0-6 if they apply at the same time.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Expressions |
| Category: Required |