bigint::bigvalue_t bigint::do_bigmult(const bigvalue_t& left, const bigvalue_t& right) {
    bigvalue_t prod;
    prod.resize(left.size() + right.size());
    int carry = 0;
    int d = 0;
    for(int i = left.size()-1; i != -1; --i) {
        carry = 0;
        for(int j = right.size()-1; j != -1; --j) {
            d = (prod.at((left.size()-1 -i) + (right.size()-1 - j))) + (left.at(i) * right.at(j)) + carry;
            //cout << (prod.at((left.size()-1 - i) + (right.size()-1 - j))) << " new ";
            //cout << (left.at(i) * right.at(j)) << " old ";
            //cout << carry << "carry" << endl;
            //cout << d << endl;
            //cout << d%10 << "<--insert"<<endl;
            //cout << d/10 << " carry" << endl;
            prod.at((left.size()-1 - i) + (right.size()-1 - j)) = d % 10;
            carry = d/10;
        }
        if(carry != 0) {
            //cout << carry << "<- insert c"<<endl;
            prod.at((right.size()-1) - -1) = carry;
        }
    }
    //trim
    return prod;
}
bigvalue_t do_bigmul(const bigvalue_t& left, const bigvalue_t& right){

   int carry = 0;
   digit_t digit = 0;
   bigvalue_t prod;
   prod.reserve(left.size() + right.size());
   for (size_t i=0; i<left.size(); ++i) {
      carry = 0;
      for (size_t j=0; j<right.size(); ++j) {
         digit = prod.at(i+j) + left.at(i)*right.at(j) + carry;
         prod.at(i+j) = digit % 10;
         carry = digit / 10;
      }
      prod.at(i+right.size()) = carry;
   }
   return prod;
}