Problems with doubles
Hi, I am making a algorithm that is very important the value of the numbers, but I have some problems, for example I need to do this operation: 1.0/14709204.0, after for I know the result of the operation I write the result of operation in one file, for example I do this:
After I open the file total.txt I can see 0.000000, and the correct result is :6.798464417*10-8, I need this result, can someone help me please?any idea?
FILE* tot = fopen("total.txt", "wb");
char buffft ;
This is an integer expression with an integer result because both operands are integers. To make it floating-point, change one or both of the values to double:
Gracias por la respuesta, pero hago esto que usted cuenta y el resultado es el mismo: 0.000.
I have written it in Spanish, this one is the translation:
Thanks for the reply, but I do this that you tell and the result is the same: 0.000.
Try the %g format modifier instead of %f.
Thanks, now in the file I can see 6.79846e-008 (the correct result), Therefore now I that the result of my operations they are correct.. Therfore the problem of my algorithm are in the other part...jeje thanks for the fast replys.