java.math.MutableBigInteger的目的是什么? [英] What is the purpose of java.math.MutableBigInteger?

查看:147
本文介绍了java.math.MutableBigInteger的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java.math.MutableBigInteger 仅在包内可用。它继承自 java.lang.Object ,并且只有一个子类( SignedMutableBigInteger ),它只能从包。

java.math.MutableBigInteger is only available from inside the package. It inherits from java.lang.Object and there is only one subclass (SignedMutableBigInteger) which is only available from inside the package.

推荐答案

/**
 * A class used to represent multiprecision integers that makes efficient
 * use of allocated space by allowing a number to occupy only part of
 * an array so that the arrays do not have to be reallocated as often.
 * When performing an operation with many iterations the array used to
 * hold a number is only reallocated when necessary and does not have to
 * be the same size as the number it represents. A mutable number allows
 * calculations to occur on the same number without having to create
 * a new number for every step of the calculation as occurs with
 *  BigIntegers.
 *
 * @see BigInteger
 * @version 1.12, 12/19/03
 * @author Michael McCloskey
 * @since 1.3
 */

Source

我猜MutableBigInteger在内部用于BigInteger重计算减速通过频繁的重新分配。我不确定为什么它不作为java.math的一部分导出。也许对可变值类有些厌恶?

I'd guess MutableBigInteger is used internally for BigInteger heavy calculations that are slowed down by frequent reallocations. I'm not sure why its not exported as part of java.math. Perhaps some distaste for mutable value classes?

澄清可变:

标准BigInteger在其整个生命周期内有一个值,给定两个BigInteger引用一个& b,a + b将始终产生具有相同值的新BigInteger。假设值为4。

To clarify "mutable":
Standard BigInteger has one value for its entire lifetime, given two BigInteger references "a" & "b", "a+b" will always yield a new BigInteger with the same value. Let's say that value is 4.

使用MutableBigInteger,a + b最初可以产生4,但在某些时候产生8,16,32或任何其他数字将来由于其他代码改变了由a和& ;;引用的对象的值(也称为变异)。 B。因此,Java中的大多数(可能是所有)值类型(Character,Short,Long,Integer,BigInteger,BigDecimal,Float,Double,even String)都是不可变的。

With MutableBigInteger, "a+b" could yield 4 initially, yet yield 8, 16, 32, or any other number at some point in the future due to OTHER code changing the values (aka. mutating) of the objects referenced by "a" & "b". Accordingly, most (perhaps all) of the value types (Character, Short, Long, Integer, BigInteger, BigDecimal, Float, Double, even String) in Java are immutable.

这篇关于java.math.MutableBigInteger的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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