![]() |
![]() |
4117 | ![]() |
||||
![]() | |||||||
| Arithmetic type - Operations | |||||||
The result of an integer division operation is being implicitly converted 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 simply because the result is assigned to an object of 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 4117:
| Rule 10.1 (Required) | The value of an expression of integer type shall not be implicitly converted to a different underlying type if: a) it is not a conversion to a wider integer type of the same signedness, or b) the expression is complex, or c) the expression is not constant and is a function argument, or d) the expression is not constant and is a return 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 |