Defined in header <complex.h> | ||
|---|---|---|
#define imaginary _Imaginary | (since C99) |
This macro expands to the keyword _Imaginary.
This is a convenience macro that makes it possible to use float imaginary, double imaginary, and long double imaginary as an alternative way to write the three pure imaginary C types float _Imaginary, double _Imaginary, and long double _Imaginary
As with any pure imaginary number support in C, this macro is only defined if the imaginary numbers are supported.
| A compiler that defines |
(since C99) (until C11) |
| Imaginary numbers are supported if | (since C11) |
Programs are allowed to undefine and perhaps redefine the imaginary macro.
#include <stdio.h>
#include <complex.h>
int main(void)
{
double imaginary i = -2.0*I; // pure imaginary
double f = 1.0; // pure real
double complex z = f + i; // complex number
printf("z = %.1f%+.1fi\n", creal(z), cimag(z));
}Output:
z = 1.0-2.0i
|
(C99) | complex type macro (keyword macro) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/c/numeric/complex/imaginary