Click here to Skip to main content
15,797,672 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to represent a+ib ??

a - real unit;

ib - imaginary unit;
Posted

How about
C
typedef struct Complex { double r; double i;} Complex;

And define all the needed function, e.g.
C
Complex add(Complex x, Complex y) { Complex z; z.r = x.r+y.r; z.i=x.i+y.i; return z; }

Etc.
Usage:
C
Complex a...; Complex b...; Complex c = add(a, b);

Cheers
Andi

PS: or you use the predefined <complex.h> implementation of the latest C standard as suggested in solution #2.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 26-Feb-13 14:49pm    
The basic idea is given, the rest of it is not that simple. A 5, anyway.
—SA
Andreas Gieriet 26-Feb-13 17:43pm    
Thanks for your 5.
Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900