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%2Fcomplex_i.html | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html (limited to 'devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html') diff --git a/devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html b/devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html new file mode 100644 index 00000000..9ccc4b52 --- /dev/null +++ b/devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html @@ -0,0 +1,40 @@ +

_Complex_I

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

The _Complex_I macro expands to a value of type const float _Complex with the value of the imaginary unit.

+

Notes

This macro may be used when I is not available, such as when it has been undefined by the application.

+

Unlike _Imaginary_I and CMPLX, use of this macro to construct a complex number may lose the sign of zero on the imaginary part.

+

Example

#include <stdio.h>
+#include <complex.h>
+ 
+#undef I
+#define J _Complex_I // can be used to redefine I
+ 
+int main(void)
+{
+    // can be used to construct a complex number
+    double complex z = 1.0 + 2.0 * _Complex_I;
+    printf("1.0 + 2.0 * _Complex_I = %.1f%+.1fi\n", creal(z), cimag(z));
+ 
+    // sign of zero may not be preserved
+    double complex z2 = 0.0 + -0.0 * _Complex_I;
+    printf("0.0 + -0.0 * _Complex_I = %.1f%+.1fi\n", creal(z2), cimag(z2));
+}

Possible output:

+
1.0 + 2.0 * _Complex_I = 1.0+2.0i
+0.0 + -0.0 * _Complex_I = 0.0+0.0i

References

See also

+ +
+
(C99)
the imaginary 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/Complex_I +

+
-- cgit v1.2.3