Essential Type Category of Complex Floating Types?

Moderators: misra-c, david ward

Post Reply
gs
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Essential Type Category of Complex Floating Types?

Post by gs » Thu Jun 27, 2013 6:11 pm

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

misra-c
Posts: 566
Joined: Thu Jan 05, 2006 1:11 pm

Re: Essential Type Category of Complex Floating Types?

Post by misra-c » Thu Sep 12, 2013 10:04 am

The essential types of complex floating point numbers should be considered as the essential types of their real and imaginary parts.

Code: Select all

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: Select all

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.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.10 The essential type model”