I'm having a problem with complex numbers. I have an equation that I must use. However, most of the time the result is complex, and I think I just need the real part. This doesn't work:
I haven't found anything about how to do this. I printed out the variable y and it usually just shows "1.#QO", but I need the real part of the result of the equation.Code:#define sigma 0.3 #include <complex> ..... complex<double> num; double y = 0; float x = ...just something num = sqrt(-2.0f*sigma*sigma*log(1.0f - x)); //apparently a pc doesn't know //how to do this y = real(num);
Please tell me there is a way do to this...