Complex number arithmetic
If the macro constant |
(since C11) |
The C programming language, as of C99, supports complex number math with the three built-in types double _Complex, float _Complex, and long double _Complex (see _Complex). When the header <complex.h> is included, the three complex number types are also accessible as double complex, float complex, long double complex.
In addition to the complex types, the three imaginary types may be supported: double _Imaginary, float _Imaginary, and long double _Imaginary (see _Imaginary). When the header <complex.h> is included, the three imaginary types are also accessible as double imaginary, float imaginary, and long double imaginary.
Standard arithmetic operators +, -, *, / can be used with real, complex, and imaginary types in any combination.
A compiler that defines |
(since C99) (until C11) |
Imaginary numbers are supported if |
(since C11) |
Defined in header
<complex.h> | ||
Types | ||
(C99) |
imaginary type macro (keyword macro) | |
(C99) |
complex type macro (keyword macro) | |
The imaginary constant | ||
(C99) |
the imaginary unit constant i (macro constant) | |
(C99) |
the complex unit constant i (macro constant) | |
(C99) |
the complex or imaginary unit constant i (macro constant) | |
Manipulation | ||
(C11)(C11)(C11) |
constructs a complex number from real and imaginary parts (function macro) | |
(C99)(C99)(C99) |
computes the real part of a complex number (function) | |
(C99)(C99)(C99) |
computes the imaginary part a complex number (function) | |
(C99)(C99)(C99) |
computes the magnitude of a complex number (function) | |
(C99)(C99)(C99) |
computes the phase angle of a complex number (function) | |
(C99)(C99)(C99) |
computes the complex conjugate (function) | |
(C99)(C99)(C99) |
computes the projection on Riemann sphere (function) | |
Exponential functions | ||
(C99)(C99)(C99) |
computes the complex base-e exponential (function) | |
|