Home | History | Annotate | Download | only in src

Lines Matching refs:other

54 void Bignum::AssignBignum(const Bignum& other) {
55 exponent_ = other.exponent_;
56 for (int i = 0; i < other.used_digits_; ++i) {
57 bigits_[i] = other.bigits_[i];
60 for (int i = other.used_digits_; i < used_digits_; ++i) {
63 used_digits_ = other.used_digits_;
144 Bignum other;
145 other.AssignUInt64(operand);
146 AddBignum(other);
150 void Bignum::AddBignum(const Bignum& other) {
152 DCHECK(other.IsClamped());
154 // If this has a greater exponent than other append zero-bigits to this.
155 // After this call exponent_ <= other.exponent_.
156 Align(other);
170 EnsureCapacity(1 + Max(BigitLength(), other.BigitLength()) - exponent_);
172 int bigit_pos = other.exponent_ - exponent_;
174 for (int i = 0; i < other.used_digits_; ++i) {
175 Chunk sum = bigits_[bigit_pos] + other.bigits_[i] + carry;
192 void Bignum::SubtractBignum(const Bignum& other) {
194 DCHECK(other.IsClamped());
195 // We require this to be bigger than other.
196 DCHECK(LessEqual(other, *this));
198 Align(other);
200 int offset = other.exponent_ - exponent_;
203 for (i = 0; i < other.used_digits_; ++i) {
205 Chunk difference = bigits_[i + offset] - other.bigits_[i] - borrow;
466 // Precondition: this/other < 16bit.
467 uint16_t Bignum::DivideModuloIntBignum(const Bignum& other) {
469 DCHECK(other.IsClamped());
470 DCHECK(other.used_digits_ > 0);
474 if (BigitLength() < other.BigitLength()) {
478 Align(other);
482 // Start by removing multiples of 'other' until both numbers have the same
484 while (BigitLength() > other.BigitLength()) {
485 // This naive approach is extremely inefficient if the this divided other
488 DCHECK(other.bigits_[other.used_digits_ - 1] >= ((1 << kBigitSize) / 16));
490 // Example this = 23 and other equals 9. -> Remove 2 multiples.
492 SubtractTimes(other, bigits_[used_digits_ - 1]);
495 DCHECK(BigitLength() == other.BigitLength());
498 // Since other has more than 0 digits we know that the access to
501 Chunk other_bigit = other.bigits_[other.used_digits_ - 1];
503 if (other.used_digits_ == 1) {
514 SubtractTimes(other, division_estimate);
517 // No need to even try to subtract. Even if other's remaining digits were 0
522 while (LessEqual(other, *this)) {
523 SubtractBignum(other);
676 void Bignum::Align(const Bignum& other) {
677 if (exponent_ > other.exponent_) {
679 // following case (a == this, b == other):
684 int zero_digits = exponent_ - other.exponent_;
716 void Bignum::SubtractTimes(const Bignum& other, int factor) {
720 b.AssignBignum(other);
724 DCHECK(exponent_ <= other.exponent_);
727 SubtractBignum(other);
732 int exponent_diff = other.exponent_ - exponent_;
733 for (int i = 0; i < other.used_digits_; ++i) {
734 DoubleChunk product = static_cast<DoubleChunk>(factor) * other.bigits_[i];
742 for (int i = other.used_digits_ + exponent_diff; i < used_digits_; ++i) {