Lines Matching defs:other
51 void Bignum::AssignBignum(const Bignum& other) {
52 exponent_ = other.exponent_;
53 for (int i = 0; i < other.used_digits_; ++i) {
54 bigits_[i] = other.bigits_[i];
57 for (int i = other.used_digits_; i < used_digits_; ++i) {
60 used_digits_ = other.used_digits_;
134 Bignum other;
135 other.AssignUInt64(operand);
136 AddBignum(other);
139 void Bignum::AddBignum(const Bignum& other) {
141 DCHECK(other.IsClamped());
143 // If this has a greater exponent than other append zero-bigits to this.
144 // After this call exponent_ <= other.exponent_.
145 Align(other);
159 EnsureCapacity(1 + std::max(BigitLength(), other.BigitLength()) - exponent_);
161 int bigit_pos = other.exponent_ - exponent_;
163 for (int i = 0; i < other.used_digits_; ++i) {
164 Chunk sum = bigits_[bigit_pos] + other.bigits_[i] + carry;
180 void Bignum::SubtractBignum(const Bignum& other) {
182 DCHECK(other.IsClamped());
183 // We require this to be bigger than other.
184 DCHECK(LessEqual(other, *this));
186 Align(other);
188 int offset = other.exponent_ - exponent_;
191 for (i = 0; i < other.used_digits_; ++i) {
193 Chunk difference = bigits_[i + offset] - other.bigits_[i] - borrow;
447 // Precondition: this/other < 16bit.
448 uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) {
450 DCHECK(other.IsClamped());
451 DCHECK_GT(other.used_digits_, 0);
455 if (BigitLength() < other.BigitLength()) {
459 Align(other);
463 // Start by removing multiples of 'other' until both numbers have the same
465 while (BigitLength() > other.BigitLength()) {
466 // This naive approach is extremely inefficient if the this divided other
469 DCHECK(other.bigits_[other.used_digits_ - 1] >= ((1 << kBigitSize) / 16));
471 // Example this = 23 and other equals 9. -> Remove 2 multiples.
473 SubtractTimes(other, bigits_[used_digits_ - 1]);
476 DCHECK(BigitLength() == other.BigitLength());
479 // Since other has more than 0 digits we know that the access to
482 Chunk other_bigit = other.bigits_[other.used_digits_ - 1];
484 if (other.used_digits_ == 1) {
495 SubtractTimes(other, division_estimate);
498 // No need to even try to subtract. Even if other's remaining digits were 0
503 while (LessEqual(other, *this)) {
504 SubtractBignum(other);
642 void Bignum::Align(const Bignum& other) {
643 if (exponent_ > other.exponent_) {
645 // following case (a == this, b == other):
650 int zero_digits = exponent_ - other.exponent_;
680 void Bignum::SubtractTimes(const Bignum& other, int factor) {
684 b.AssignBignum(other);
688 DCHECK(exponent_ <= other.exponent_);
691 SubtractBignum(other);
696 int exponent_diff = other.exponent_ - exponent_;
697 for (int i = 0; i < other.used_digits_; ++i) {
698 DoubleChunk product = static_cast<DoubleChunk>(factor) * other.bigits_[i];
706 for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) {