将实数转换为复数是否会将C中的虚部设置为0
?以下是我正在try 做的事情:
#include <complex.h>
#include <stdio.h>
int main(void){
float complex a;
double b = 1.0;
a = (float complex) b ; /* Does this convert to float and set
complex part of a to 0 (according to C standards) ?*/
a = (float) b ; /* If we also do this, does the compiler set the imaginary part to 0?
or we have to explicitly give b + 0.0f*I ?*/
printf("%f \n", cimagf(a));
return 0;
}
更具体地说,它是否保留虚数部分未初始化(因为复数表示为两个实数)?