Chromium Code Reviews| Index: runtime/vm/bigint_operations.cc |
| =================================================================== |
| --- runtime/vm/bigint_operations.cc (revision 13805) |
| +++ runtime/vm/bigint_operations.cc (working copy) |
| @@ -776,9 +776,18 @@ |
| RawBigint* BigintOperations::Modulo(const Bigint& a, const Bigint& b) { |
| Bigint& quotient = Bigint::Handle(); |
| - Bigint& modulo = Bigint::Handle(); |
| - DivideRemainder(a, b, "ient, &modulo); |
| - return modulo.raw(); |
| + Bigint& remainder = Bigint::Handle(); |
| + Bigint& zero = Bigint::Handle(BigintOperations::Zero()); |
| + DivideRemainder(a, b, "ient, &remainder); |
| + // Emulating code in Integer::ArithmeticOp (Euclidian modulo). |
| + if (BigintOperations::Compare(remainder, zero) == -1) { |
|
floitsch
2012/10/19 08:18:54
if (remainder.isNegative())
srdjan
2012/10/19 14:56:02
Done.
|
| + if (BigintOperations::Compare(b, zero) == -1) { |
|
floitsch
2012/10/19 08:18:54
if (b.isNegative())
srdjan
2012/10/19 14:56:02
Done.
|
| + return BigintOperations::Subtract(remainder, b); |
| + } else { |
| + return BigintOperations::Add(remainder, b); |
| + } |
| + } |
| + return remainder.raw(); |
| } |