mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
bignum divmod bug
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecd1aab526
commit
0dedfa849c
1 changed files with 4 additions and 1 deletions
5
bignum.c
5
bignum.c
|
@ -804,7 +804,10 @@ bigdivmod(x, y, div, mod, modulo)
|
|||
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
|
||||
if (div) *div = bignorm(z);
|
||||
if (mod) {
|
||||
if (!RBIGNUM(y)->sign) t2 = -(long)t2;
|
||||
if (!RBIGNUM(x)->sign) t2 = -(long)t2;
|
||||
if (modulo && RBIGNUM(x)->sign != RBIGNUM(y)->sign) {
|
||||
t2 = t2 + yds[0] * (RBIGNUM(y)->sign ? 1 : -1);
|
||||
}
|
||||
*mod = INT2NUM(t2);
|
||||
}
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue