### 2.4. Complex Floating-Point Types (C99)

C99 supports mathematical calculations with complex numbers. The 1999 standard introduced complex floating-point types and extended the mathematical library to include complex arithmetic functions. These functions are declared in the header file complex.h , and include for example the trigonometric functions csin( ), ctan( ), and so on (see Chapter 15).

A complex number z can be represented in Cartesian coordinates as z = x + y x i, where x and y are real numbers, and i is the imaginary unit, defined by the equation i2 = -1. The number x is called the real part and y the imaginary part of z.

In C, a complex number is represented by a pair of floating-point values for the real and imaginary parts. Both parts have the same type, whether float, double, or long double. Accordingly, these are the three complex floating-point types:

• float _Complex

• double _Complex

• long double _Complex

Each of these types has the same size and alignment as an array of two float, double, or long double elements.

The header file complex.h defines the macros complex and I. The macro complex is a synonym for the keyword _Complex. The macro I represents the imaginary unit i, and has the type const float _Complex:

```    #include <complex.h>
// ...
double complex z = 1.0 + 2.0 * I;
z *= I;      // Rotate z through 90° counterclockwise around the origin.
``` 