首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

cimag

在头文件<math.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)

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

该函数完全为所有可能的输入指定,并且不受math_errhandling中描述的任何错误的影响。

笔记

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

代码语言:javascript
复制
#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));
}

输出:

代码语言:javascript
复制
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)

扫码关注腾讯云开发者

领取腾讯云代金券