命名空间
变体
操作

cimagf, cimag, cimagl

来自 cppreference.cn
< c‎ | numeric‎ | complex
定义于头文件 <complex.h>
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)
定义于头文件 <tgmath.h>
#define cimag( z )
(4) (since C99)
1-3) 返回 z 的虚部。
4) 类型泛型宏:如果 z 的类型是 long double complex, long double imaginary, 或 long double,则调用 cimagl。如果 z 的类型是 float complex, float imaginary, 或 float,则调用 cimagf。如果 z 的类型是 double complex, double imaginary, double, 或任何整数类型,则调用 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 函数 (页码:197)
  • 7.25 类型泛型数学 <tgmath.h> (页码:373-375)
  • G.7 类型泛型数学 <tgmath.h> (页码:545)
  • C99 标准 (ISO/IEC 9899:1999)
  • 7.3.9.2 cimag 函数 (页码:178-179)
  • 7.22 类型泛型数学 <tgmath.h> (页码:335-337)
  • G.7 类型泛型数学 <tgmath.h> (页码:480)

[编辑] 参见

(C99)(C99)(C99)
计算复数的实部
(函数) [编辑]