命名空间
变体
操作

cimagf, cimag, cimagl

来自 cppreference.cn
< c‎ | 数值‎ | 复数
定义在头文件 <complex.h>
float       cimagf( float complex z );
(1) (C99 起)
double      cimag( double complex z );
(2) (C99 起)
long double cimagl( long double complex z );
(3) (C99 起)
定义于头文件 <tgmath.h>
#define cimag( z )
(4) (C99 起)
1-3) 返回 z 的虚部。
4) 类型通用宏:如果 z 的类型是 long double complexlong double imaginarylong double,则调用 cimagl。如果 z 的类型是 float complexfloat imaginaryfloat,则调用 cimagf。如果 z 的类型是 double complexdouble imaginarydouble 或任何整数类型,则调用 cimag

目录

[编辑] 参数

z - 复数参数

[编辑] 返回值

z 的虚部。

此函数对所有可能的输入都完全指定,不受 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)
  • 7.3.9.2 cimag 函数 (p: 197)
  • 7.25 类型通用数学 <tgmath.h> (p: 373-375)
  • G.7 类型通用数学 <tgmath.h> (p: 545)
  • C99 标准 (ISO/IEC 9899:1999)
  • 7.3.9.2 cimag 函数 (p: 178-179)
  • 7.22 类型通用数学 <tgmath.h> (p: 335-337)
  • G.7 类型通用数学 <tgmath.h> (p: 480)

[编辑] 另请参阅

(C99 起)(C99 起)(C99 起)
计算复数的实部
(函数) [编辑]
C++ 文档 用于 imag