CMPLX宏
概要:
#include <complex.h> double complex CMPLX(double x, double y);
描述:
该宏是一个函数式宏,可以构造一个double complex类型的复数,该复数实数部分具有参数x的值,虚数部分具有参数y的值。
构造得到的复数应适合初始化具有静态存储期限的对象或者线程存储期限的对象,前提是两个参数都合适。
宏CMPLX的实现就像实现支持虚数类型一样,其定义如下所示:
#define CMPLX(x, y) ((double complex)((double)(x) + _Imaginary_I*(double)(y)))
参数:
double x
参数为一个double类型的浮点数。
double y
参数为一个double类型的浮点数。
返回值:
该宏返回x + iy。
范例:
|
|
输出:
CMPLX(1.0, 2.0) = 1.00 + 2.00i
注:使用ideone编译。
相关内容:
CMPLXF | 构造float complex类型复数的宏。 |
CMPLXL | 构造long double complex类型复数的宏。 |