title: How to perform BigInteger multiplication on char vectors?
body: <p>I'm implementing a BigInt in c++ and am trying to overload the multiplication operator. I'm storing large integers in a char vector. </p>
  
  <pre><code>vector&lt;char&gt; storage;
  </code></pre>
  
  <p>Here is what I did to implement operator*(int)</p>
  
  <pre><code>BigInt BigInt::operator*(int x)
  {
  int extra = 0;
  int dec_mod = pow(10, this-&gt;storage.size());
  
  for (auto &amp; g : storage) {
      g = g * x + extra;
      int mod_g = g % dec_mod;
      extra = g / dec_mod;
      g = mod_g;
  }
  
  while (extra &gt; 0) {
      storage.push_back(extra % dec_mod);
      extra /= dec_mod;
  }
  
  return *this;
  }
  </code></pre>
  
  <p>The operator*(bigInt) function returns wrong answers. For example, 33 * 4 returns 1212 and not 132.This was my attempt at writing the overloaded operator* which takes a bigint object:</p>
  
  <pre><code>BigInt BigInt::operator*(BigInt bigN) {
  int carry = 0;
  
  for (int i = bigN.storage.size()-1; i &gt;= 0; i--) {
  
      for (int j = this-&gt;storage.size()-1; j &gt;= 0; j--) {
  
          int val = (this-&gt;storage.at(i) * bigN.storage.at(j)) + carry;
          this-&gt;storage.push_back(val % 10);
          carry = val / 10;
      }
  
  }
  return *this;
  }
  </code></pre>
  
  <p>It looks like the logic in the carry is flawed, but i'm not sure how to fix it.</p>