L
Lane Straatman
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
int main(void)
{
_Complex z1, z2, z3;
z1 = .4 + .7i;
z2 = pow(z1, 2);
z3 = z1 * z1;
printf("%f, %f \n", z1);
printf("%f, %f \n", z2);
printf("%f, %f \n", z3);
system("PAUSE");
return 0;
}
In this program, z2 is not equal to z3 . z3 looks correct. On my
implementation (devcpp on its maiden voyage), z2 becomes the real part
squared, and the complex part zeros out and is probably undefined.
Q1)With C99's new types, how does one use the old math functions?
Q2)Is complex or _Complex a better type defn? LS
#include <stdlib.h>
#include <complex.h>
int main(void)
{
_Complex z1, z2, z3;
z1 = .4 + .7i;
z2 = pow(z1, 2);
z3 = z1 * z1;
printf("%f, %f \n", z1);
printf("%f, %f \n", z2);
printf("%f, %f \n", z3);
system("PAUSE");
return 0;
}
In this program, z2 is not equal to z3 . z3 looks correct. On my
implementation (devcpp on its maiden voyage), z2 becomes the real part
squared, and the complex part zeros out and is probably undefined.
Q1)With C99's new types, how does one use the old math functions?
Q2)Is complex or _Complex a better type defn? LS