From: Simon Tatham Date: Sun, 9 Mar 2014 23:14:24 +0000 (+0000) Subject: Fix occasional 'min fragment 1.11022e-16' glitch. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=13849e71956f8a3a2142cadd24c4f2006a328a04;p=matchsticks-search.git Fix occasional 'min fragment 1.11022e-16' glitch. Seems to happen in multicore mode when the first worker reports a near-zero value of 'best', and then set_best reduces it to a negative number when it applies the rounding fudge, leading to the max_frags limits being set to negative things and all other workers' results being thrown away in preconsider_ok(). --- diff --git a/main.c b/main.c index a57bd72..8259c35 100644 --- a/main.c +++ b/main.c @@ -147,8 +147,10 @@ static void set_best(double new_best) { * subtract a fudge factor from our target. */ double near_best = best * 0.98 - 0.02; - n_max_frags = ceil(n / near_best) - 1; - m_max_frags = ceil(m / near_best) - 1; + if (near_best > 0) { + n_max_frags = ceil(n / near_best) - 1; + m_max_frags = ceil(m / near_best) - 1; + } } /*----- multicore support -----*/