Tag: biginteger

如何将string转换为BigInteger?

我试图从标准input中读取一些非常大的数字,并将它们加在一起。 但是,要添加到BigInteger,我需要使用BigInteger.valueOf(long); : private BigInteger sum = BigInteger.valueOf(0); private void sum(String newNumber) { // BigInteger is immutable, reassign the variable: sum = sum.add(BigInteger.valueOf(Long.parseLong(newNumber))); } 这工作正常,但作为BigInteger.valueOf()只需要很long ,我不能添加数字大于long的最大值(9223372036854775807)。 每当我尝试添加9223372036854775808或更多,我得到一个NumberFormatException(这是完全预期)。 有没有像BigInteger.parseBigInteger(String) ?

BigInteger没有限制意味着什么?

我看着这个与大整数有关的stackoverflow问题 ,特别是我不明白这行(斜体字): 在BigInteger类中, 我没有任何限制,并且有一些有帮助的function,但是将漂亮的代码转换为BigInteger类,特别是在基本运算符不在那里工作,而且必须使用这个类的函数。 我不知道我在想什么,但是要expression一些没有限制的东西,你需要无限的记忆? 这里有什么窍门?

如何findJava BigInteger的平方根?

有没有一个库可以findBigInteger的平方根? 我希望它脱机计算 – 只有一次,而不是在任何循环内。 所以即使计算上昂贵的解决scheme也没关系。 我不想find一些algorithm和实现。 现成的解决scheme将是完美的。

JSON转移bigint:12000000000002539转换为12000000000002540?

我正在传输原始数据,例如[{id: 12000000000002539, Name: "Some Name"}]并在parsing后得到对象[{id: 12000000000002540, Name: "Some Name"}] ID到string似乎帮助。 但有没有更好的方法来正确传输bigint数据?

从整数转换为BigInteger

我想知道是否有任何方式将Integertypes的variables转换为BigInteger。 我试图强制转换整型variables,但我得到一个错误,说不可转换的types。

Java:如何使用BigInteger?

我有这段代码,这是不工作的: BigInteger sum = BigInteger.valueOf(0); for(int i = 2; i < 5000; i++) { if (isPrim(i)) { sum.add(BigInteger.valueOf(i)); } } 总和variables总是0.我做错了什么?

BigInteger有上限吗?

可能重复: BigInteger没有限制意味着什么? BigInteger的Javadoc没有定义任何最大值或最小值。 但是,它确实说: (强调加) 不可变的任意精度整数 即使在理论上是否有这样的最大值? 或者, BigInteger运作方式根本不同,除了计算机上可用的内存量之外,实际上并没有最大限度的提高?

在C大数字图书馆

我正在做一个项目,需要真正的大数字,最多100位数字。 我读过,Java支持大整数( java.Math.BigInteger ),我想知道是否有类似的东西在C + +。 所以,这里是我的问题:是否有一个标准或非标准的C ++库实现大整数? 注意:如果没有大整数的标准实现,我想要一个简单的非标准的。 提前致谢。

C ++处理非常大的整数

我正在使用RSAalgorithm进行encryption/解密,并且为了解密文件,您必须处理一些相当大的值。 更具体地说,像 P = C^d % n = 62^65 % 133 现在,这真的是唯一的计算,病态的做法。 我曾尝试使用Matt McCutchen的BigInteger库,但在链接过程中遇到了很多编译错误,例如: encryption.o(.text+0x187):encryption.cpp: undefined reference to `BigInteger::BigInteger(int)' encryption.o(.text+0x302):encryption.cpp: undefined reference to `operator<<(std::ostream&, BigInteger const&)' encryption.o(.text$_ZNK10BigIntegermlERKS_[BigInteger::operator*(BigInteger const&) const]+0x63):encryption.cpp: undefined reference to `BigInteger::multiply(BigInteger const&, BigInteger const&)' 所以我想知道什么是处理来自RSAalgorithm的真正大整数的最好方法。 我听说有可能将声明你的variables为双倍长,所以… long long decryptedCharacter; 但我不确定究竟可以存储多大的整数。 那么举个例子,我尝试使用dev C ++编译并运行下面的程序: #include iostream #include "bigint\BigIntegerLibrary.hh" using namespace std; int main() { […]

如何在不使用java.math.BigInteger的情况下处理Java中的大数字

我将如何去做算术,+ – / *%!,使用任意大的整数而不使用java.math.BigInteger ? 例如,90的阶乘在Java中返回0。 我希望能够解决这个问题。