In C language, the _imaginary macro is used to obtain the imaginary part of a complex number. The usage is as follows: declare a complex variable in the format a bi (a is the real part, b is the imaginary part). Use the _imaginary(z) function to get the imaginary part of the complex number z. The _imaginary function returns type double even if the input complex number is of type complex float.

Usage of _imaginary in C language
In C language, _imaginary is A macro used to represent the imaginary part of complex numbers. Its usage is as follows:
Format:
<code class="c">#include <complex.h> double _imaginary(complex double z); float _imaginary(complex float z);</code>
Parameters:
z: A complex number represented as a bi, where a is the real part and b is the imaginary part. Return value:
b, the imaginary part of the complex number z. Example:
<code class="c">#include <complex.h>
int main() {
complex double z = 3.0 + 4.0i;
// 获取虚部
double imaginary_part = _imaginary(z);
// 输出虚部
printf("虚部:%f\n", imaginary_part);
return 0;
}</code>Output:
<code>虚部:4.000000</code>
Notes:
_imaginary can only be used for complex numbers, not real numbers. The result of _imaginary is always of type double, even if the input complex number is of type complex float. The above is the detailed content of _imaginary usage in c language. For more information, please follow other related articles on the PHP Chinese website!