6.10. Complex Numbers

6.10 Complex Numbers

ISO C99 supports complex floating data types, and as an extension GCC supports them in C90 mode and in C++. GCC also supports complex integer data types which are not part of ISO C99. You can declare complex types using the keyword _Complex. As an extension, the older GNU keyword __complex__ is also supported.

For example, ‘_Complex double x;’ declares x as a variable whose real part and imaginary part are both of type double. ‘_Complex short int y;’ declares y to have real and imaginary parts of type short int; this is not likely to be useful, but it shows that the set of complex types is complete.

To write a constant with a complex data type, use the suffix ‘i’ or ‘j’ (either one; they are equivalent). For