cimag
返回复数的虚部的值。
接口定义
C interface:
float cimagf(float complex x);
double cimag(double complex x);
long double cimagl(long double complex x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
返回x的虚部的值y,y ∈ (-INF, +INF)。
依赖
C: "km.h"
示例
C interface:
// typical usage double x1 = INFINITY, y1 = INFINITY; double x2 = 2.0, y2 = 3.0; double x3 = -2.5, y3 = -3.4; double x4 = NAN, y4 = NAN; double x5 = 0, y5 = 0; // print result printf("/*\n"); printf(" * cimag(%.2f + %.2f*I) = %.6f\n", x1, y1, cimag(__builtin_complex(x1, y1))); printf(" * cimag(%.2f + %.2f*I) = %.6f\n", x2, y2, cimag(__builtin_complex(x2, y2))); printf(" * cimag(%.2f + %.2f*I) = %.6f\n", x3, y3, cimag(__builtin_complex(x3, y3))); printf(" * cimag(%.2f + %.2f*I) = %.6f\n", x4, y4, cimag(__builtin_complex(x4, y4))); printf(" * cimag(%.2f + %.2f*I) = %.6f\n", x5, y5, cimag(__builtin_complex(x5, y5))); printf(" **/\n"); /* * cimag(inf + inf*I) = inf * cimag(2.00 + 3.00*I) = 3.000000 * cimag(-2.50 + -3.40*I) = -3.400000 * cimag(nan + nan*I) = nan * cimag(0.00 + 0.00*I) = 0.000000 **/
父主题: 复数函数