I am in the middle of porting some C ++ code to java, and I continue to work in cases where no one writes, he continued to do the following:
double c = (1.0/(a+1.0)*pow(b, a+1.0));
double d = (1./(integral(gamma, dmax)-integral(gamma, dmin)))*(integral(gamma+1, dmax)-integral(gamma+1, dmin));
Instead:
double c = pow(b, a+1.0)/(a+1.0);
double d = (integral(gamma+1, dmax)-integral(gamma+1, dmin))/(integral(gamma, dmax)-integral(gamma, dmin));
The second one looks much clearer, and if I'm not mistaken about the order of operations in C ++, they should do the same. Is there any reason to do the first, not the second? The only thing I could think of would be a strange case with precision.
source
share