From: trevor_hansen Date: Fri, 1 Oct 2010 14:35:44 +0000 (+0000) Subject: Bugfix. Unsigned modulus of zero returned 1, it should return 0. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=72bbf50e504c721df5260adcc080c639ddb0b0c0;p=francis%2Fstp.git Bugfix. Unsigned modulus of zero returned 1, it should return 0. git-svn-id: https://stp-fast-prover.svn.sourceforge.net/svnroot/stp-fast-prover/trunk/stp@1023 e59a4935-1847-0410-ae03-e826735625c1 --- diff --git a/src/simplifier/consteval.cpp b/src/simplifier/consteval.cpp index d0ddeab..a5d8b66 100644 --- a/src/simplifier/consteval.cpp +++ b/src/simplifier/consteval.cpp @@ -450,8 +450,14 @@ namespace BEEV if (_bm->UserFlags.division_by_zero_returns_one_flag && CONSTANTBV::BitVector_is_empty(tmp1)) { - // Expecting a division by zero. Just return one. - OutputNode = _bm->CreateOneConst(outputwidth); + // a = bq + r, where b!=0 implies r < b. q is quotient, r remainder. i.e. a/b = q. + // It doesn't matter what q is when b=0, but r needs to be 0. + if (k == BVMOD) + OutputNode = _bm->CreateZeroConst(outputwidth); + else + OutputNode = _bm->CreateOneConst(outputwidth); + // Expecting a division by zero. Just return one. + } else {