|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Problem with complex number function cimag()
Consider the following C code:
#include <stdio.h>
#include <complex.h>
int main(void)
{
double complex a = 2.0 + 0.0 * I;
double complex b = 1.5 + .5 * I;
double complex c = cpow(a, b);
double complex csum = a + b;
double r = creal(c);
double i = cimag(c);
printf("%f %f\n", r, i);
printf("%f %f\n", creal(csum), cimag(csum));
return 0;
}
I want to raise the complex number 2.0 +0.0i to the complex power 1.5 +
0.5i.
The result of this calculation is approximately 2.66 + .96i. The above code
compiled with DMC outputs the correct value for the real part but 0.0i for
the
imaginary part. In the second printf() statement cimag() outputs the correct
value.
Can anybody give me some insight where the problem lies?
JS
Jan 13 2004
"John Smith" <jsmith email.com> wrote in message news:bu1o5e$11pp$1 digitaldaemon.com... Jan 19 2004
I want youe help in writting the expresion in c++. kindly mentioned to me how to write this expression. thanks Ejaz Ahmed Sep 04 2005
I want youe help in writting the expresion in c++. kindly mentioned to me how to write this expression. thanks Ejaz Ahmed Sep 04 2005
I want youe help in writting the expresion in c++. kindly mentioned to me how to write this expression. thanks Ejaz Ahmed aajaz1 gmail.com Sep 04 2005
Ejaz Ahmed wrote:I want youe help in writting the expresion in c++. kindly mentioned to me how to write this expression. thanks Ejaz Ahmed aajaz1 gmail.com Sep 08 2005
|