Re: for loop issue

Originally Posted by
reubenpatterson
, but when I put the calculations first, the finalPos is already calculated incorrectly (because the formula breaks down) and the subtraction is done from that bad value, not the previous good value.
Store the previous value before calculation and use it if the test fails, otherwise use the new one.
"It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
Richard P. Feynman