MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / TBigInteger

Class TBigInteger

CodenameOne/src/com/codename1/util/TBigInteger.java:34–1588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32/// discouraged. In simple words: Do NOT implement any bit fields based on
33/// BigInteger.
34class TBigInteger {
35
36
37 /* Fields used for the internal representation. */
38
39 /// The `BigInteger` constant 0.
40 public static final TBigInteger ZERO = new TBigInteger(0, 0);
41 /// The `BigInteger` constant 1.
42 public static final TBigInteger ONE = new TBigInteger(1, 1);
43 /// The `BigInteger` constant 10.
44 public static final TBigInteger TEN = new TBigInteger(1, 10);
45 /// The `BigInteger` constant -1.
46 static final TBigInteger MINUS_ONE = new TBigInteger(-1, 1);
47 /// The `BigInteger` constant 0 used for comparison.
48 static final int EQUALS = 0;
49 /// The `BigInteger` constant 1 used for comparison.
50 static final int GREATER = 1;
51 /// The `BigInteger` constant -1 used for comparison.
52 static final int LESS = -1;
53 /// All the `BigInteger` numbers in the range [0,10] are cached.
54 static final TBigInteger[] SMALL_VALUES = {ZERO, ONE, new TBigInteger(1, 2), new TBigInteger(1, 3),
55 new TBigInteger(1, 4), new TBigInteger(1, 5), new TBigInteger(1, 6), new TBigInteger(1, 7),
56 new TBigInteger(1, 8), new TBigInteger(1, 9), TEN};
57 static final TBigInteger[] TWO_POWS;
58
59 static {
60 TWO_POWS = new TBigInteger[32];
61 for (int i = 0; i < TWO_POWS.length; i++) {
62 TWO_POWS[i] = TBigInteger.valueOf(1L << i);
63 }
64 }
65
66 /// The magnitude of this big integer. This array holds unsigned little
67 /// endian digits. For example: `13` is represented as [ 13 ]
68 /// `-13` is represented as [ 13 ] `2^32 + 13` is represented as
69 /// [ 13, 1 ] `2^64 + 13` is represented as [ 13, 0, 1 ] `2^31`
70 /// is represented as [ Integer.MIN_VALUE ] The magnitude array may be longer
71 /// than strictly necessary, which results in additional trailing zeros.
72 transient int[] digits;
73 /// The length of this in measured in ints. Can be less than digits.length().
74 transient int numberLength;
75 /// The sign of this.
76 transient int sign;
77 private transient int firstNonzeroDigit = -2;
78
79 /// Cache for the hash code.
80 private transient int hashCode = 0;
81
82 /// Constructs a random non-negative `BigInteger` instance in the range
83 /// [0, 2^(numBits)-1].
84 ///
85 /// #### Parameters
86 ///
87 /// - `numBits`: maximum length of the new `BigInteger` in bits.
88 ///
89 /// - `rnd`: is an optional random generator to be used.
90 ///
91 /// #### Throws

Callers

nothing calls this directly

Calls 1

valueOfMethod · 0.95

Tested by

no test coverage detected