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

﹥>﹥吖頭↗ 提交于 2019-11-30 17:40:24

If you have the String representation of your binary number, provide it to this overloaded BigInteger constructor to create an instance:

BigInteger(String val, int radix);

In your case, radix is clearly 2, i.e. you can use something like this:

BigInteger yourNumber = new BigInteger("101000101110...1010", 2);
amicngh

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

 String binaryString = "1010110101011010101010101101010101100101011010001010001100101110";
 BigInteger bigInt = new BigInteger(binaryString, 2);
    String binaryValue = "11111111";
    BigInteger bi = new BigInteger(binaryValue, 2);  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!