Precedence

Killer this one:

avg_dist = ((avg_dist*i)+lineLength)/i+1;

will return something completely different to

avg_dist = ((avg_dist*i)+lineLength)/(i+1);

(while creating a rolling average of distances between points on a line)
Time to find bug: ~20mins