blob: 5b1db5b0f3d632c3e9f137e3ccdca57f23c929c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<h1 id="firstHeading" class="firstHeading">imaginary</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><complex.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define imaginary _Imaginary</pre>
</td> <td class="t-dcl-nopad"> </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> </table> <p>This macro expands to the keyword <a href="../../keyword/_imaginary" title="c/keyword/ Imaginary"><code>_Imaginary</code></a>.</p>
<p>This is a convenience macro that makes it possible to use <code>float imaginary</code>, <code>double imaginary</code>, and <code>long double imaginary</code> as an alternative way to write the three pure imaginary C types <code>float _Imaginary</code>, <code>double _Imaginary</code>, and <code>long double _Imaginary</code></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><a href="http://en.cppreference.com/w/c/numeric/complex/Imaginary_I"><span class="kw745">_Imaginary_I</span></a></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>Programs are allowed to undefine and perhaps redefine the <code>imaginary</code> macro.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h>
#include <complex.h>
int main(void)
{
double imaginary i = -2.0*I; // pure imaginary
double f = 1.0; // pure real
double complex z = f + i; // complex number
printf("z = %.1f%+.1fi\n", creal(z), cimag(z));
}</pre></div> <p>Output:</p>
<div class="text source-text"><pre data-language="c">z = 1.0-2.0i</pre></div> </div> <h3 id="References"> References</h3> <ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul>
<li> 7.3.1/5 imaginary (p: 136) </li>
<li> G.6/1 imaginary (p: 391-392) </li>
</ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.3.1/5 imaginary (p: 188) </li>
<li> G.6/1 imaginary (p: 537) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.3.1/3 imaginary (p: 170) </li>
<li> G.6/1 imaginary (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" title="c/numeric/complex/complex"> <span class="t-lines"><span>complex</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> complex type macro <br> <span class="t-mark">(keyword macro)</span> </td>
</tr> </table> <div class="_attribution">
<p class="_attribution-p">
© 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" class="_attribution-link">https://en.cppreference.com/w/c/numeric/complex/imaginary</a>
</p>
</div>
|