C
数值 | Numerics

cimagf

cimagf, cimag, cimagl

在头文件中定义
float cimagf( float complex z (1)(since C99)
double cimag( double complex z (2)(since C99)
long double cimagl( long double complex z (3)(since C99)
Defined in header <tgmath.h>
#define cimag( z )(4)(since C99)

1-3)返回的虚部z

4)式泛型宏:如果z具有类型long double complexlong double imaginarylong doublecimagl被调用。如果z有类型float complexfloat imaginary或者floatcimagf被调用。如果z有类型double complexdouble imaginarydouble,或任何整数类型,cimag被调用。

参数

z-复杂的论点

返回值

虚构的部分z

This function is fully specified for all possible inputs and is not subject to any errors described in math_errhandling.

笔记

对于任何复杂的变量zz == creal(z) + I*cimag(z)

#include <stdio.h> #include <complex.h> int main(void) { double complex z = 1.0 + 2.0*I; printf("%f%+fi\n", creal(z), cimag(z) }

输出:

1.000000+2.000000i

参考

  • C11标准(ISO / IEC 9899:2011):