CMPLX, CMPLXF, CMPLXL — make a complex value
#include <complex.h>
double complex CMPLX(double x, double y);
float complex CMPLXF(float x, float y);
long double complex CMPLXL(long double x, long double y);
[CX] The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the requirements described here and the ISO C standard is unintentional. This volume of POSIX.1-2024 defers to the ISO C standard.The CMPLX macros shall expand to an expression of the specified complex type, with the real part having the (converted) value of x and the imaginary part having the (converted) value of y. The resulting expression shall be suitable for use as an initializer for an object with static or thread storage duration, provided both arguments are likewise suitable.
The CMPLX macros return the complex value x + i y (where i is the imaginary unit).
These macros shall behave as if the implementation supported imaginary types and the definitions were:
#define CMPLX(x, y) ((double complex)((double)(x) + \ _Imaginary_I * (double)(y))) #define CMPLXF(x, y) ((float complex)((float)(x) + \ _Imaginary_I * (float)(y))) #define CMPLXL(x, y) ((long double complex)((long double)(x) + \ _Imaginary_I * (long double)(y)))
No errors are defined.
None.
None.
None.
None.
XBD <complex.h>
First released in Issue 8. Included for alignment with the ISO/IEC 9899:2018 standard.
return to top of page