From 26ef04fa9cd265d8f10cd46dcf2712100af4da88 Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Mon, 8 Apr 2013 15:13:57 +0000 Subject: [PATCH] Fix bug in bignum implementation. R=mstarzinger@chromium.org BUG= Review URL: https://chromiumcodereview.appspot.com/13454019 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14167 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/bignum.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bignum.cc b/src/bignum.cc index 9436322..c8b61ee 100644 --- a/src/bignum.cc +++ b/src/bignum.cc @@ -735,6 +735,13 @@ void Bignum::BigitsShiftLeft(int shift_amount) { void Bignum::SubtractTimes(const Bignum& other, int factor) { +#ifdef DEBUG + Bignum a, b; + a.AssignBignum(*this); + b.AssignBignum(other); + b.MultiplyByUInt32(factor); + a.SubtractBignum(b); +#endif ASSERT(exponent_ <= other.exponent_); if (factor < 3) { for (int i = 0; i < factor; ++i) { @@ -758,9 +765,9 @@ void Bignum::SubtractTimes(const Bignum& other, int factor) { Chunk difference = bigits_[i] - borrow; bigits_[i] = difference & kBigitMask; borrow = difference >> (kChunkSize - 1); - ++i; } Clamp(); + ASSERT(Bignum::Equal(a, *this)); } -- 2.7.4