MISRA Discussion Forums
Essential Type Category of Complex Floating Types? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.10 The essential type model (https://forum.misra.org.uk/forumdisplay.php?fid=165)
+---- Thread: Essential Type Category of Complex Floating Types? (/showthread.php?tid=967)



Essential Type Category of Complex Floating Types? - gs - 27-06-2013

C99 provides for complex floating point types. What is the essential type category of each?


Re: Essential Type Category of Complex Floating Types? - misra-c - 12-09-2013

The essential types of complex floating point numbers should be considered as the essential types of their real and imaginary parts.
Code:
float _Complex f1 = 3.0f + 2.0f*_Complex_I;
In this both the real and imaginary parts will have an "essentially float" type.

The MISRA C:2012 rules for conversions/arithmetic operations etc: will then apply to these types.
e.g.
Code:
double _Complex d1 =  3.0 + 2.0*_Complex_I;
float _Complex f2  = d1;
This will violate rule 10.3 since both the real and imaginary parts are assigned to a narrower essential type.