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

Unified Diff: runtime/lib/bigint.dart

Issue 1062753004: Fix bigint division (issue 23238). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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/language/vm/regress_23238_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/bigint.dart
===================================================================
--- runtime/lib/bigint.dart (revision 45241)
+++ runtime/lib/bigint.dart (working copy)
@@ -1042,10 +1042,13 @@
if (_compareDigits(r_digits, r_used, t_digits, t_used) >= 0) {
assert(i == r_used);
r_digits[r_used++] = 1; // Quotient = 1.
- r_digits[r_used] = 0; // Leading zero.
// Subtract divisor from remainder.
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
+ } else {
+ // Account for possible carry in _mulAdd step.
+ r_digits[r_used++] = 0;
}
+ r_digits[r_used] = 0; // Leading zero for 64-bit processing.
// Negate y so we can later use _mulAdd instead of non-existent _mulSub.
var ny_digits = new Uint32List(y_used + 2);
ny_digits[y_used] = 1;
@@ -1137,10 +1140,13 @@
if (_compareDigits(r_digits, r_used, t_digits, t_used) >= 0) {
assert(i == r_used);
r_digits[r_used++] = 1; // Quotient = 1.
- r_digits[r_used] = 0; // Leading zero.
// Subtract divisor from remainder.
_absSub(r_digits, r_used, t_digits, t_used, r_digits);
+ } else {
+ // Account for possible carry in _mulAdd step.
+ r_digits[r_used++] = 0;
}
+ r_digits[r_used] = 0; // Leading zero for 64-bit processing.
// Negated y_digits passed in ny_digits allow the use of _mulAdd instead of
// unimplemented _mulSub.
// ny_digits is read-only and has y_used digits (possibly including several
« no previous file with comments | « no previous file | tests/language/vm/regress_23238_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698