3 ms·
https://en.cppreference.com/w/c/numeric/complex/imaginary https://en.cppreference.com/w/c/numeric/complex/imaginary #include <complex.h> ... double imagi
by eesmith 4y ago
https://en.cppreference.com/w/c/numeric/complex/imaginary https://en.cppreference.com/w/c/numeric/complex/imaginary
#include <complex.h>
...
double imaginary i = -2.0*I; // pure imaginary
double f = 1.0; // pure real
double complex z = f + i; // complex number
from gcc's complex.h:
#ifdef __GNUC__
#if __STDC_VERSION__ < 199901
#define _Complex __complex__
#endif
#define _Complex_I ((float _Complex)1.0i)
#endif
#ifdef __generic
_Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
"_Complex_I must be of type float _Complex");
#endif
#define complex _Complex
#define I _Complex_I
- anyfoo 4y agoAh. I even entertained the fact that it may be for complex numbers, but... honestly didn't know C added support for that! This despite using complex numbers a lot, just not in C so far. I always assumed I would have to use an external library.