From: Marco Costalba Date: Fri, 18 Aug 2017 09:02:35 +0000 (-0700) Subject: Clarify stats range X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=9c35b9365d75a3522cee47536419534b1de91f48;ds=inline Clarify stats range Current update formula ensures that the possible value range is [-32 * D, 32 * D]. So we never overflow if abs(32 * D) < INT16_MAX Thanks to Joost and mstembera to clarify this. No functional change. --- diff --git a/src/movepick.h b/src/movepick.h index d6451f6b..db0ba3c4 100644 --- a/src/movepick.h +++ b/src/movepick.h @@ -38,12 +38,8 @@ struct StatBoards : public std::array, Size1> { void update(T& entry, int bonus, const int D) { - assert([&]{ - int v = entry + bonus * 32 - entry * abs(bonus) / D; - return INT16_MIN < v && v < INT16_MAX; - }()); - - assert(abs(bonus) <= D); // Consistency check for below formula + assert(abs(bonus) <= D); // Ensure range is [-32 * D, 32 * D] + assert(abs(32 * D) < INT16_MAX); // Ensure we don't overflow entry += bonus * 32 - entry * abs(bonus) / D;