summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fcomplex%2Fimaginary_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%2Fimaginary_i.html
new repository
Diffstat (limited to 'devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html')
-rw-r--r--devdocs/c/numeric%2Fcomplex%2Fimaginary_i.html46
1 files changed, 46 insertions, 0 deletions
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 @@
+ <h1 id="firstHeading" class="firstHeading">_Imaginary_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 _Imaginary_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>_Imaginary_I</code> macro expands to a value of type <code>const float _Imaginary</code> with the value of the imaginary unit.</p>
+<p>As with any pure imaginary number support in C, this macro is only defined if the imaginary numbers are supported.</p>
+<table class="t-rev-begin"> <tr class="t-rev t-since-c99 t-until-c11">
+<td> <p>A compiler that defines <code>__STDC_IEC_559_COMPLEX__</code> is not required to support imaginary numbers. POSIX recommends checking if the macro <code>_Imaginary_I</code> is defined to identify imaginary number support.</p>
+</td> <td>
+<span class="t-mark-rev t-since-c99">(since C99)</span><br><span class="t-mark-rev t-until-c11">(until C11)</span>
+</td>
+</tr> <tr class="t-rev t-since-c11">
+<td> <p>Imaginary numbers are supported if <code>__STDC_IEC_559_COMPLEX__</code> is defined.</p>
+</td> <td><span class="t-mark-rev t-since-c11">(since C11)</span></td>
+</tr> </table> <h3 id="Notes"> Notes</h3> <p>This macro allows for the precise way to assemble a complex number from its real and imaginary components, e.g. with <code><span class="br0">(</span><span class="kw4">double</span> <a href="http://en.cppreference.com/w/c/numeric/complex/complex"><span class="kw743">complex</span></a><span class="br0">)</span><span class="br0">(</span><span class="br0">(</span><span class="kw4">double</span><span class="br0">)</span>x <span class="sy2">+</span> _Imaginary_I <span class="sy2">*</span> <span class="br0">(</span><span class="kw4">double</span><span class="br0">)</span>y<span class="br0">)</span></code>. This pattern was standardized in C11 as the macro <code><a href="http://en.cppreference.com/w/c/numeric/complex/CMPLX"><span class="kw747">CMPLX</span></a></code>. Note that if <code><a href="http://en.cppreference.com/w/c/numeric/complex/Complex_I"><span class="kw744">_Complex_I</span></a></code> is used instead, this expression is allowed to convert negative zero to positive zero in the imaginary position.</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;
+#include &lt;math.h&gt;
+
+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));
+}</pre></div> <p>Output:</p>
+<div class="text source-text"><pre data-language="c">z1 = 0.0+Infi
+z2 = NaN+Infi</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.3.1/5 _Imaginary_I (p: 188) </li>
+<li> G.6/1 _Imaginary_I (p: 537) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.3.1/3 _Imaginary_I (p: 170) </li>
+<li> G.6/1 _Imaginary_I (p: 472) </li>
+</ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="complex_i" title="c/numeric/complex/Complex I"> <span class="t-lines"><span>_Complex_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 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/Imaginary_I" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/Imaginary_I</a>
+ </p>
+</div>