void mp_int<A,T>::pow2(typename mp_int<A,T>::size_type b) { grow_capacity(b / digit_bits + 1); // set size_ to where the bit will go size_ = b / digit_bits + 1; // set all bits to zero std::memset(digits_, 0, size_ * sizeof(digit_type)); // put the single bit in its place digits_[b / digit_bits] = digit_type(1) << (b % digit_bits); }
big_unsigned& operator+= (const big_unsigned& __rhs) { if (_M_blk.size() < __rhs.size()) resize(__rhs.size(), traits_type::digit_type(0)); digit_type _carry(0); auto _outIter = std::transform(__rhs.begin(), __rhs.end(), begin(), begin(), [&_carry, this](const digit_type __d1, const digit_type __d2) { auto _tmp = traits_type::sum(__d1, __d2, _carry); _carry = _tmp/this->_M_base; return _tmp % this->_M_base; }); std::all_of(_outIter, end(), [&_carry, this, &_outIter](const digit_type __d1) { auto _tmp = traits_type::sum(__d1, _carry); *_outIter++ = _tmp % this->_M_base; _carry = _tmp/this->_M_base; return _carry != digit_type(0); }); if (_carry == digit_type(1)) prepend(_carry); prune_zeros(); return (*this); }
big_unsigned(unsigned long long __rhs) : bignum_base(10) { do { _M_blk.push_back(digit_type(__rhs % _M_base)); __rhs /= _M_base; } while (__rhs > 0ull); }
// modifiers big_unsigned() : bignum_base(10) {_M_blk.push_back(digit_type(0));}