Jon - 1 month ago 15

Java Question

I've been searching around for quite a while, and I've found almost nothing on how

`BigInteger`

`BigInteger`

From what I've found, I am assuming that all of arbitrary precision classes, like

`BigInteger`

`BigDecimal`

I'm asking because I have been working on my own implementation of something like

`BigInteger`

`Long.MAX_VALUE`

Thanks in advance.

Answer

With an `int[]`

From the source:

```
/**
* The magnitude of this BigInteger, in <i>big-endian</i> order: the
* zeroth element of this array is the most-significant int of the
* magnitude. The magnitude must be "minimal" in that the most-significant
* int ({@code mag[0]}) must be non-zero. This is necessary to
* ensure that there is exactly one representation for each BigInteger
* value. Note that this implies that the BigInteger zero has a
* zero-length mag array.
*/
final int[] mag;
```