Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: runtime/vm/bigint_operations.cc

Issue 11192074: Fix bigint modulo operation. Fixes bug 6056 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/corelib/big_integer_vm_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bigint_operations.cc
===================================================================
--- runtime/vm/bigint_operations.cc (revision 13822)
+++ runtime/vm/bigint_operations.cc (working copy)
@@ -776,9 +776,17 @@
RawBigint* BigintOperations::Modulo(const Bigint& a, const Bigint& b) {
Bigint& quotient = Bigint::Handle();
- Bigint& modulo = Bigint::Handle();
- DivideRemainder(a, b, &quotient, &modulo);
- return modulo.raw();
+ Bigint& remainder = Bigint::Handle();
+ DivideRemainder(a, b, &quotient, &remainder);
+ // Emulating code in Integer::ArithmeticOp (Euclidian modulo).
+ if (remainder.IsNegative()) {
+ if (b.IsNegative()) {
+ return BigintOperations::Subtract(remainder, b);
+ } else {
+ return BigintOperations::Add(remainder, b);
+ }
+ }
+ return remainder.raw();
}
« no previous file with comments | « no previous file | tests/corelib/big_integer_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698