How does BigInteger store its data?

前端 未结 3 1160
天命终不由人
天命终不由人 2020-12-30 20:02

I\'ve been searching around for quite a while, and I\'ve found almost nothing on how BigInteger actually holds its numbers. Are they an array of chars? Somethin

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 20:42

    With an int[]

    From the source:

    /**
     * The magnitude of this BigInteger, in big-endian 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;
    

提交回复
热议问题