I'm in the middle of porting some c++ code to java, and I keep running across instances where whoever wrote it kept doing 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 of:
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 seems much clearer, and unless I'm wrong about the order of operations in C++ they should do the same thing. Is there some reason to do the first and not the second? The only thing I could think of would be some weird case with precision.