From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html (limited to 'devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html') diff --git a/devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html b/devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html new file mode 100644 index 00000000..553a7a26 --- /dev/null +++ b/devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html @@ -0,0 +1,46 @@ +

_Imaginary_I

Defined in header <complex.h>
#define _Imaginary_I /* unspecified */
+
(since C99)

The _Imaginary_I macro expands to a value of type const float _Imaginary with the value of the imaginary unit.

+

As with any pure imaginary number support in C, this macro is only defined if the imaginary numbers are supported.

+ + + + +

A compiler that defines __STDC_IEC_559_COMPLEX__ is not required to support imaginary numbers. POSIX recommends checking if the macro _Imaginary_I is defined to identify imaginary number support.

+
+(since C99)
(until C11) +

Imaginary numbers are supported if __STDC_IEC_559_COMPLEX__ is defined.

+
(since C11)

Notes

This macro allows for the precise way to assemble a complex number from its real and imaginary components, e.g. with (double complex)((double)x + _Imaginary_I * (double)y). This pattern was standardized in C11 as the macro CMPLX. Note that if _Complex_I is used instead, this expression is allowed to convert negative zero to positive zero in the imaginary position.

+

Example

#include <stdio.h>
+#include <complex.h>
+#include <math.h>
+ 
+int main(void)
+{
+    double complex z1 = 0.0 + INFINITY * _Imaginary_I;
+    printf("z1 = %.1f%+.1fi\n", creal(z1), cimag(z1));
+ 
+    double complex z2 = 0.0 + INFINITY * _Complex_I;
+    printf("z2 = %.1f%+.1fi\n", creal(z2), cimag(z2));
+}

Output:

+
z1 = 0.0+Infi 
+z2 = NaN+Infi

References

See also

+ +
+
(C99)
the complex unit constant i
(macro constant)
+
(C99)
the complex or imaginary unit constant i
(macro constant)
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/numeric/complex/Imaginary_I +

+
-- cgit v1.2.3