BigInteger会不会溢出? [英] Does BigInteger ever overflows?

查看:127
本文介绍了BigInteger会不会溢出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

API文档说


规则中有关溢出的所有细节都会被忽略,因为
BigIntegers是必要的大,以适应操作的结果。

All of the details in the Spec concerning overflow are ignored, as BigIntegers are made as large as necessary to accommodate the results of an operation.

这是否意味着假设有足够的可用内存,BigInteger永远不会溢出?如果是这样,为什么我们让一些类型溢出而一些不会?

Does this implies BigInteger will never overflow assuming you have sufficient memory available ? If so why do we let some "type" overflow and some don't ?

随着语言的发展,它是否会偏向程序员隐藏溢出机制的类型?

As the language evolves, will it favor the types which hide overflowing mechanism from the programmers ?

推荐答案

假设你有足够的内存来处理它,BigInteger永远不会溢出。

BigInteger will never overflow assuming you have enough memory to handle it.

回答你为什么我们让某些类型溢出而不是其他类型的问题:

To answer your question of why we let some types overflow and not others:

BigInteger实际上不是一种类型。这是一堂课。它是一个包装类,旨在为您提供与int相同的功能,但允许您使用尽可能大的数字,而不必担心溢出。

BigInteger is not really a type. It's a class. It's a wrapper class designed to give you the same functionality as an int, but allows you to use numbers as big as you need without the worry of overflow.

类型溢出因为它们只是几个字节(确切数量取决于类型)的内存,一旦少量内存溢出,数字也是如此。

Types do overflow because they are simply a couple of bytes (exact amount depends on the type) of memory, and once that small amount of memory overflows, so do the numbers.

没有类溢出,除非它是专门设计的(或者如果资源不足)。定义一个类,它包含足够的内存,包含其他类或其他数据结构。

No class "overflows" unless it is specifically designed to do so (or if you run out of resources). A class is defined with enough memory for everything it contains, which would mostly be references to other classes or other data structures.

这篇关于BigInteger会不会溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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