[previous] MISRA-C:2004  Rule  10.4:  (Required) [next] The value of a complex expression of floating type shall only be cast to a floating type that is narrower or of the same size.
If a cast is to be used on any complex expression, the type of cast that may be applied is severely restricted. Conversions on complex expressions are often a source of confusion and it is therefore wise to be cautious. In order to comply with these rules, it may be necessary to use a temporary variable and introduce an extra statement.

... ( float32_t )( f64a + f64b )              /* compliant     */
... ( float64_t )( f32a + f32b )              /* not compliant */
... ( float64_t )f32a                         /* compliant     */
... ( float64_t )( s32a / s32b )              /* not compliant */
... ( float64_t )( s32a > s32b )              /* not compliant */
... ( float64_t )s32a / ( float32_t )s32b     /* compliant     */


QAC messages that encompass this guideline:

4392 A composite expression of 'essentially floating' type (%1s) is being cast to a wider floating type, '%2s'.
4395 A composite expression of 'essentially floating' type (%1s) is being cast to a different type category, '%2s'.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents