-2
I’m doing some work that needs complex mathematical equations. And I’m having a problem early on, when I try to do the 1/result split, the answer is always 0,000.
I have tried using double, float, Pow() and the result is the same. (all values are different from 0)
    capacitor = (2*pi*resistor*fc);
    printf("%lf\n", capacitor);
    capacitor = 1/capacitor;
    printf("%lf", capacitor);
Answer: 0.0000
Change of
2for2.0in multiplication solves the problem? Or the1for1.0. I haven’t dealt with C for a long time, but it may be that he’s interpreting the constant as an integer and then the division turns out to be an integer. It talks a little about this: https://answall.com/a/254001/100416– Rafael Tavares
I think it would help to post the whole code because the declaration of variables can influence the question.
– Motta
Write for example
capacitor = (2*pi*(double)resistor*fc);andcapacitor = 1/(double)capacitor;forcing the compiler to calculate the whole expression asdouble. And, of course, declarecapacitoras such...– arfneto