[previous] 1267 [next] Suffixed floating constant cast to another type.
Arithmetic type - Casts

A constant of floating type is being cast to a different floating type. Perhaps this is intended but be aware that the type of a floating constant depends on its suffix.

Remember, an unsuffixed floating constant is always of type double. A constant of type float is suffixed with "F", and a constant of type long double is suffixed with "L".

For example:


/*PRQA S 2017,3121,3198,3408,3447 ++*/

extern float       fta;
extern double      dba;
extern long double lda;

extern void foo(void)
{
    fta = (float)12.34;                /* Message 1268 */
    fta = (float)12.34L;               /* Message 1267 */

    dba = (double)12.34F;              /* Message 1267 */
    dba = (double)12.34L;              /* Message 1267 */

    lda = (long double)12.34F;         /* Message 1267 */
    lda = (long double)12.34;          /* Message 1268 */
}

See also:

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