[previous] 4117 [next] Result of integer division operation implicitly converted to a floating type.
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                                            */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents