A complex number combines a real component with an imaginary component. C places complex floating-point numbers alongside unsigned integers, signed integers, and real floating-point numbers; the complex family contains float complex, double complex, and long double complex, distinguished by precision. section 5.2
Writing complex constants
Include <complex.h> before using the complex macros: #include <complex.h> double complex z = 0.5 + 0.5 * I; float complex w = 0.5F + 0.5F * I; double complex pair = CMPLX(0.5, 0.5); I denotes the imaginary unit, with I*I equal to −1. CMPLX combines real and imaginary floating-point values into a double complex value; CMPLXF and CMPLXL select float complex and long double complex. C provides no literal syntax dedicated to complex constants, so these macros supply the practical notation. When real and imaginary operands use different floating-point types, the result is implicitly converted to the wider type. section 5.3.1
Table 5.1. Base types according to the four main type classes. Types with a gray background don’t allow for arithmetic; they are promoted before doing arithmetic. Type char is special since it can be unsigned or signed, depending on the platform. All types in this table are considered to be distinct types, even if they have the same class and precision. (view table figure)
| Class |
Systematic name |
Other name |
Rank |
|
|---|---|---|---|---|
| Integers | Unsigned | _Bool | bool | 0 |
| unsigned char | 1 | |||
| unsigned short | 2 | |||
| unsigned int | unsigned | 3 | ||
| unsigned long | 4 | |||
| unsigned long long | 5 | |||
| [Un]signed | char | 1 | ||
| signed char | 1 | |||
| signed short | short | 2 | ||
| Signed | signed int | signed or int | 3 | |
| signed long | long | 4 | ||
| signed long long | long long | 5 | ||
| Floating point | Real | float | ||
| double | ||||
| long double | ||||
| Complex | float _Complex | float complex | ||
| double _Complex | double complex | |||
| long double _Complex | long double complex | |||
Compare complex types with the other base-type classes, their systematic names, and their precision-related distinctions. section 5.2


