![]() |
![]() |
4118 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | |||||||
The result of an integer division operation is being cast to a floating type. This division operation will be performed in integer arithmetic and so any remainder will be discarded. Don't be confused into thinking that the division is conducted in a floating type just because the result is being cast to a floating type. For example:
/*PRQA S 584,3198,3227,3408,3447 ++*/
extern float ft;
void foo(unsigned int m, unsigned int n)
{
ft = m / n; /* Message 4117 + 3774 (implicit conversion, int to float) */
ft = (float)(m / n); /* Message 4118 */
}
MISRA-C:2004 Rules applicable to message 4118:
| Rule 10.3 (Required) | The value of a complex expression of integer type shall only be cast to a type of the same signedness that is no wider than the underlying type of the expression. |
See also:
![]() | ||
| 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 |