你如何转换成二进制数Java中的BigInteger的? [英] How do you convert A binary number to a BigInteger in Java?

查看:146
本文介绍了你如何转换成二进制数Java中的BigInteger的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个非常大的二进制值转换成相应的十进制数。由于这是我使用的BigInteger一个大的整数。那么,如何转换这种二进制数为BigInteger?

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 BigInteger?

推荐答案

如果您有字符串重新您的二进制数presentation,它提供给此重载的BigInteger 构造函数创建一个实例:

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);

在你的情况下,基数显然是2,即可以使用这样的:

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

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

这篇关于你如何转换成二进制数Java中的BigInteger的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆