BigInteger没有限制意味着什么? [英] What does BigInteger having no limit mean?

查看:244
本文介绍了BigInteger没有限制意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调查了这个有关Big Integer的stackoverflow问题,具体来说我不明白这个line(斜体字):

I looked into this stackoverflow question relating to Big Integer and specifically I do not understand this line (the words in italics):


在BigInteger类中,我没有限制并且有一些有用的
在那里运行但是将你漂亮的
代码转换为使用BigInteger类是非常令人沮丧的,特别是当原始
运算符不能在那里工作时你必须使用这个类中的函数。

In the BigInteger class, I have no limits and there are some helpful functions there but it is pretty depressing to convert your beautiful code to work with the BigInteger class, specially when primitive operators don't work there and you must use functions from this class.

我不知道我错过了什么,但代表一些没有限制的东西,你需要无限的记忆?什么是诀窍?

I don't know what I am missing but to represent something that has no limit you would require infinite memory ? Whats is the trick here ?

推荐答案

没有理论限制。 BigInteger 类为所要求的所有数据位分配所需的内存。

There is no theoretical limit. The BigInteger class allocates as much memory as it needs for all the bits of data it is asked to hold.

但是,有一些实际的限制,由可用的内存决定。还有进一步的技术限制,虽然你不太可能受到影响:有些方法假设这些位可以通过 int 索引进行寻址,所以当你进入时会出现问题高于 Integer.MAX_VALUE 位。

There are, however, some practical limits, dictated by the memory available. And there are further technical limits, although you're very unlikely to be affected: some methods assume that the bits are addressable by int indexes, so things will start to break when you go above Integer.MAX_VALUE bits.

这篇关于BigInteger没有限制意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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