Correctly round evaluation to grain size
authorMarco Costalba <mcostalba@gmail.com>
Mon, 21 Feb 2011 11:45:51 +0000 (12:45 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 23 Feb 2011 22:52:51 +0000 (23:52 +0100)
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/evaluate.cpp

index 3c0be19d2aa0c75d9974b6a86dfe61491d94c0df..53afc447aed901b1d39df15f63e9461cadb3cc83 100644 (file)
@@ -1105,7 +1105,7 @@ namespace {
     Value ev = Value((eg * int(sf)) / SCALE_FACTOR_NORMAL);
 
     int result = (mg_value(v) * int(ph) + ev * int(128 - ph)) / 128;
-    return Value(result & ~(GrainSize - 1));
+    return Value((result + GrainSize / 2) & ~(GrainSize - 1));
   }