aboutsummaryrefslogtreecommitdiff
path: root/types.cpp
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-12 09:51:08 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-12 09:51:08 +0800
commitc5364249b2600f25155f4c7ac206b3d6ca0e5b06 (patch)
treed00c85150a826c9d131790fa877d49a53cf80be4 /types.cpp
parent88b91db506969f3ed7752bfe9e1e916f5e098942 (diff)
rectified a bug in `modulo`
Diffstat (limited to 'types.cpp')
-rw-r--r--types.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/types.cpp b/types.cpp
index 8611cc6..de7ef66 100644
--- a/types.cpp
+++ b/types.cpp
@@ -892,7 +892,7 @@ NumObj *IntNumObj::mod(NumObj *_r) {
const mpz_class &rval = static_cast<IntNumObj*>(_r)->val;
if (rval == 0) throw NormalError(RUN_ERR_NUMERIC_OVERFLOW);
mpz_class ret = val % rval;
- if (sgn(ret) != sgn(rval))
+ if (ret != 0 && sgn(ret) != sgn(rval))
ret = ret + rval;
return new IntNumObj(ret);
}