CMPLXF, CMPLX, CMPLXL
来自 cppreference.cn
定义于头文件 <complex.h> |
||
float complex CMPLXF( float real, float imag ); |
(自 C11 起) | |
double complex CMPLX( double real, double imag ); |
(自 C11 起) | |
long double complex CMPLXL( long double real, long double imag ); |
(自 C11 起) | |
这些宏中的每一个都展开为一个表达式,该表达式求值为指定复数类型的值,其中实部的值为 real
(转换为指定的参数类型),虚部的值为 imag
(转换为指定的参数类型)
这些表达式适用于用作具有静态或线程存储持续时间的对象,只要表达式 real
和 imag
也适用。
目录 |
[编辑] 参数
real | - | 要返回的复数的实部 |
imag | - | 要返回的复数的虚部 |
[编辑] 返回值
由 real
和 imag
组成的复数,分别作为实部和虚部。
[编辑] 注意
这些宏的实现方式就好像支持虚数类型一样 (即使它们在其他情况下不受支持,并且 _Imaginary_I 实际上是未定义的),并且定义如下
#define CMPLX(x, y) ((double complex)((double)(x) + _Imaginary_I * (double)(y))) #define CMPLXF(x, y) ((float complex)((float)(x) + _Imaginary_I * (float)(y))) #define CMPLXL(x, y) ((long double complex)((long double)(x) + \ _Imaginary_I * (long double)(y)))
[编辑] 示例
运行此代码
输出
z = 0.0-0.0i
[编辑] 参考文献
- C11 标准 (ISO/IEC 9899:2011)
- 7.3.9.3 CMPLX 宏 (p: 197)
[编辑] 参见
(C99) |
虚数单位常量 i (宏常量) |
C++ 文档 关于 complex
|