title: Reverse bits in an integer : stoi exception
body: <p>I am getting out of range exception when using <code>stoi</code>. I am trying to reverse bits of an integer by first putting the bits in a string and then converting that string to integer using stoi.</p>
  <pre><code>uint32_t reverseBits(uint32_t n) {
      string nu_bits;
      for(int i=0; i&lt;32;i++){
         // cout&lt;&lt;((n&gt;&gt;i)&amp;1);
         nu_bits.push_back(((n&gt;&gt;i)&amp;1)+'0');
      }
      cout&lt;&lt;endl;
      cout&lt;&lt;stoi(nu_bits);
      return n;
  }
  </code></pre>
  <p>terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi</p>