If I define these variables:
double x0, xn, h;
int n;
and I have this math expression:
h = (xn - x0)/n;
Do I need to do n in double before doing division for maximum precision, as in
h = (xn - x0)/ (double) n;
I wrote a program to check above, but both expressions give the same answers. I understand that C will stimulate an integer to a double type, since the variables xn and x0 are of type double, but, oddly enough, in the book, the second cast expression was emphasized.
My question will be if I think correctly.
Thank you so much...
source
share