![]() |
![]() |
4119 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | REFERENCE - ISO:C90-6.2.1.3 Conversions - Floating and Integral | ||||||
The result of a floating point calculation has been explicitly cast to an integral type. In an operation like this, any fractional part of the floating value is simply discarded, i.e. the value is rounded towards zero, Is this the intended behaviour ? For example:
/*PRQA S 3121,3198,3199,3203,3408,3447 ++*/
extern float fta;
extern float ftb;
extern void foo(void)
{
int n;
n = (int)fta; /* */
n = (int)(fta * ftb); /* Message 4119 */
n = (int)(fta / ftb); /* Message 4119 */
n = (int)(fta + ftb); /* Message 4119 */
n = (int)(fta - ftb); /* Message 4119 */
n = (fta * ftb); /* Message 3804 */
n = (fta / ftb); /* Message 3804 */
n = (fta + ftb); /* Message 3804 */
n = (fta - ftb); /* Message 3804 */
}
No MISRA-C:2004 Rules applicable to message 4119
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |