How do you convert A binary number to a BigInteger in Java?

后端 未结 3 1571
忘了有多久
忘了有多久 2021-01-04 02:09

I needed to convert a very big binary value into its decimal equivalent. As it is a big integer I was using BigInteger. So how do I convert this binary number to a BigIntege

3条回答
  •  执笔经年
    2021-01-04 02:49

    If you have binary String you can convert it to BigInteger like this:

     String binaryString = "1010110101011010101010101101010101100101011010001010001100101110";
     BigInteger bigInt = new BigInteger(binaryString, 2);
    

提交回复
热议问题