getting 2'complement of a binary number stored as a string in an input file
<p>I am a beginner. I am trying to get 2's complement of a binary number which stored in string 
<code>sou2_reg='000000000000000000000000000000011'</code>. If I will do <code>sou2_reg[32]</code> it gives me <code>1</code>, the last bit.</p>

<p>Now what I want to do is getting 2's complement of <code>sou2_reg</code>. I tried this but its not working. Can you please give me some piece of code?? Really appreciate</p>

<pre><code>string twosComp(string number) {

     if ( number == 0 ) { return "1"; }
     if ( number == 1 ) { return "0"; }

     if ( number % 2 == 0 ) {
         return twosComp(number / 2) + "1";
     }
     else {
         return twosComp(number / 2) + "0";
     }
}
</code></pre>
