title: BigInteger NumberFormatException on valid big binary string
body: <p>So, I was using BigInteger to convert some binary string to a numeric representation and ended up getting stuck on a weird error.</p>
  
  <p>When this line is code runs, it raises a NumberFormatException:</p>
  
  <pre><code>BigInteger temp = new BigInteger(strbuf.toString(), 2);
  </code></pre>
  
  <p>where strbuf has the following string (made up only of zeros and ones):</p>
  
  <pre><code>"1001110000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010"
  </code></pre>
  
  <p>At first I thought perhaps the string or value were too big, but the following standalone java class compiles and runs just fine:</p>
  
  <pre><code>import java.math.BigInteger;
  
  class test {
      public static void main(String[] argv) {
          StringBuffer strbuf = new StringBuffer("1001110000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010");
          BigInteger big = new BigInteger(strbuf.toString(), 2);
          System.out.println(big);
      }
  }
  </code></pre>
  
  <p>Is there something Im missing here? Why does the same code with apparently same values fail to run on my main application?</p>
  
  <p>The exception message:</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "1001110000000100"
      at java.lang.NumberFormatException.forInputString(Unknown Source)
      at java.lang.Integer.parseInt(Unknown Source)
      at java.math.BigInteger.&lt;init&gt;(Unknown Source)
      at org.app.star.pad(star.pad:42)
  </code></pre>