Fixed modulo function which affected 'random' procedure. (See bug #647541)
This commit is contained in:
@ -516,12 +516,14 @@ static num num_mod(num a, num b) {
|
||||
e1=num_ivalue(a);
|
||||
e2=num_ivalue(b);
|
||||
res=e1%e2;
|
||||
if(res*e2<0) { /* modulo should have same sign as second operand */
|
||||
e2=labs(e2);
|
||||
if(res>0) {
|
||||
res-=e2;
|
||||
} else {
|
||||
res+=e2;
|
||||
/* modulo should have same sign as second operand */
|
||||
if (res > 0) {
|
||||
if (e2 < 0) {
|
||||
res*=-1L;
|
||||
}
|
||||
} else {
|
||||
if (e2 > 0) {
|
||||
res*=-1L;
|
||||
}
|
||||
}
|
||||
ret.value.ivalue=res;
|
||||
|
||||
Reference in New Issue
Block a user