When I try to find the value of a BigInteger
data type for 223,000, I am not able to see the value.
当我试图找到223,000的BigInteger数据类型的值时,我无法看到该值。
However, for calculations up to 222,000, I could display the BigInteger
value without any problems.
但是,对于高达222,000的计算,我可以毫无问题地显示BigInteger值。
Is there any solution or reason for this?
这有什么解决方案或原因吗?
4 个解决方案
#1
I tried the following in order to make a BigInteger
representation of 2^23000
:
为了使BigInteger表示为2 ^ 23000,我尝试了以下操作:
BigInteger bi = new BigInteger("2");
bi = bi.pow(23000);
System.out.println(bi);
And the number displayed was a very large number spanning 6925 digits. (I won't paste it here as it will span over 100 lines.)
显示的数字是一个非常大的数字,跨越6925位数。 (我不会在这里粘贴它,因为它将超过100行。)
This is with Java 6 SE version 1.6.0_12 in Windows XP.
这与Windows XP中的Java 6 SE版本1.6.0_12有关。
According the API Specification, BigInteger
is an arbitrary-precision integer value which means it should be able to cope with very large integer values.
根据API规范,BigInteger是一个任意精度的整数值,这意味着它应该能够处理非常大的整数值。
#2
It works fine for me on GNU/Linux. What do you mean you can't "display" it? What's your code and what error/problem do you get?
它在GNU / Linux上适用于我。你是什么意思,你不能“显示”它?您的代码是什么以及您得到的错误/问题是什么?
#3
this limit for BigInteger is around 2^16 billion, though it has been noted that some functions don't behave correctly after about 2^2 billion.
BigInteger的这个限制大约是2 ^ 160亿,尽管已经注意到一些功能在大约2 ^ 20亿之后没有正常运行。
My guess is that your console or IDE has problems displaying very long lines.
我的猜测是你的控制台或IDE在显示很长的行时出现问题。
#4
Do you need the whole thing? There is also a BigInteger.modpow(power, modulus) method which raises the integer value to the specified power and returning result % modulus -- commonly used in cryptography. This is also MUCH faster when dealing with very large exponents.
你需要整件事吗?还有一个BigInteger.modpow(幂,模数)方法,它将整数值提升到指定的幂并返回结果%模数 - 通常用于加密。处理非常大的指数时,这也快得多。
#1
I tried the following in order to make a BigInteger
representation of 2^23000
:
为了使BigInteger表示为2 ^ 23000,我尝试了以下操作:
BigInteger bi = new BigInteger("2");
bi = bi.pow(23000);
System.out.println(bi);
And the number displayed was a very large number spanning 6925 digits. (I won't paste it here as it will span over 100 lines.)
显示的数字是一个非常大的数字,跨越6925位数。 (我不会在这里粘贴它,因为它将超过100行。)
This is with Java 6 SE version 1.6.0_12 in Windows XP.
这与Windows XP中的Java 6 SE版本1.6.0_12有关。
According the API Specification, BigInteger
is an arbitrary-precision integer value which means it should be able to cope with very large integer values.
根据API规范,BigInteger是一个任意精度的整数值,这意味着它应该能够处理非常大的整数值。
#2
It works fine for me on GNU/Linux. What do you mean you can't "display" it? What's your code and what error/problem do you get?
它在GNU / Linux上适用于我。你是什么意思,你不能“显示”它?您的代码是什么以及您得到的错误/问题是什么?
#3
this limit for BigInteger is around 2^16 billion, though it has been noted that some functions don't behave correctly after about 2^2 billion.
BigInteger的这个限制大约是2 ^ 160亿,尽管已经注意到一些功能在大约2 ^ 20亿之后没有正常运行。
My guess is that your console or IDE has problems displaying very long lines.
我的猜测是你的控制台或IDE在显示很长的行时出现问题。
#4
Do you need the whole thing? There is also a BigInteger.modpow(power, modulus) method which raises the integer value to the specified power and returning result % modulus -- commonly used in cryptography. This is also MUCH faster when dealing with very large exponents.
你需要整件事吗?还有一个BigInteger.modpow(幂,模数)方法,它将整数值提升到指定的幂并返回结果%模数 - 通常用于加密。处理非常大的指数时,这也快得多。