Question: Representing complex numbers in C

lim at ecs.umass.edu lim at ecs.umass.edu
Thu Feb 28 03:50:55 AEST 1991


Hi,

I'd appreciated it if anyone out there can help me out with this problem. It 
concerns representation of complex numbers in C. I understand that Fortran has 
a data type COMPLEX that allows complex variables to be treated like any int, 
float, or double. I need to do the following in C:

COMPLEX x, y, z;
z = x + y;
etc.

The following won't work, obviously...

struct
{
 double real;
 double imaginary;
}
COMPLEX;

Thanks in advance.


Jonathan Lim



More information about the Comp.lang.c mailing list