Bug 738951 - (modulo n m) may fail for m >= 46342 (in 32-bit) or m >= 3037000501 (in 64-bit)

This commit is contained in:
Pedro Gimeno 2016-05-29 00:13:22 +02:00 committed by Michael Schumacher
parent 48b8df2f14
commit f665e4cfa9
1 changed files with 2 additions and 2 deletions

View File

@ -498,7 +498,7 @@ static num num_rem(num a, num b) {
e1=num_ivalue(a);
e2=num_ivalue(b);
res=e1%e2;
/* remainder should have same sign as second operand */
/* remainder should have same sign as first operand */
if (res > 0) {
if (e1 < 0) {
res -= labs(e2);
@ -520,7 +520,7 @@ static num num_mod(num a, num b) {
e2=num_ivalue(b);
res=e1%e2;
/* modulo should have same sign as second operand */
if (res * e2 < 0) {
if ((res < 0) != (e2 < 0) && res) { /* if their sign is different... */
res+=e2;
}
ret.value.ivalue=res;