Synopsis: | Floating values should not be converted to integral types except through use of standard library routines. |
Language: | C |
Severity Level: | 2 |
Category: | CONVERSIONS |
Description: |
Since mixed precision arithmetic involves implementation defined and undefined behaviour, it is safer to avoid implicit conversions between floating and integral types. For ANSI-C 99 compilers this comes down to using the function " #include So instead of using an implicit conversion such as int i; float fl; i = fl; /* implicit conversion from float to int */ one should make it explicit by using the defined library function: int i; float fl; i = f2i(fl); /* explicit conversion from float to int */ |