summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html
new repository
Diffstat (limited to 'devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html')
-rw-r--r--devdocs/c/numeric%2Fcomplex%2Fcomplex_i.html40
1 files changed, 40 insertions, 0 deletions
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 @@
+ <h1 id="firstHeading" class="firstHeading">_Complex_I</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;complex.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define _Complex_I /* unspecified */</pre>
+</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <p>The <code>_Complex_I</code> macro expands to a value of type <code>const float _Complex</code> with the value of the imaginary unit.</p>
+<h3 id="Notes"> Notes</h3> <p>This macro may be used when <code>I</code> is not available, such as when it has been undefined by the application.</p>
+<p>Unlike <code><a href="imaginary_i" title="c/numeric/complex/Imaginary I">_Imaginary_I</a></code> and <code><a href="cmplx" title="c/numeric/complex/CMPLX">CMPLX</a></code>, use of this macro to construct a complex number may lose the sign of zero on the imaginary part.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;stdio.h&gt;
+#include &lt;complex.h&gt;
+
+#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));
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">1.0 + 2.0 * _Complex_I = 1.0+2.0i
+0.0 + -0.0 * _Complex_I = 0.0+0.0i</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul><li> 7.3.1/4 _Complex_I (p: TBD) </li></ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul><li> 7.3.1/4 _Complex_I (p: 136) </li></ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul><li> 7.3.1/4 _Complex_I (p: 188) </li></ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul><li> 7.3.1/2 _Complex_I (p: 170) </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="imaginary_i" title="c/numeric/complex/Imaginary I"> <span class="t-lines"><span>_Imaginary_I</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> the imaginary unit constant i <br> <span class="t-mark">(macro constant)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="i" title="c/numeric/complex/I"> <span class="t-lines"><span>I</span></span></a></div>
+<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> the complex or imaginary unit constant i <br> <span class="t-mark">(macro constant)</span> </td>
+</tr> </table> <div class="_attribution">
+ <p class="_attribution-p">
+ &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
+ <a href="https://en.cppreference.com/w/c/numeric/complex/Complex_I" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/Complex_I</a>
+ </p>
+</div>