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

Class BigInteger

CodenameOne/src/com/codename1/util/BigInteger.java:10–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9/// A simplified version of big integer from the bouncy castle implementation
10public class BigInteger {
11
12 public static final BigInteger ZERO = new BigInteger(0, new int[0]);
13 public static final BigInteger ONE = valueOf(1);
14 TBigInteger peer;
15
16 private BigInteger() {
17 peer = new TBigInteger(0, new int[0]);
18 }
19
20
21 private BigInteger(int signum, int[] mag) {
22 peer = new TBigInteger(signum, mag);
23 }
24
25 public BigInteger(String sval) throws NumberFormatException {
26 this(sval, 10);
27 }
28
29 public BigInteger(String sval, int rdx) throws NumberFormatException {
30 peer = new TBigInteger(sval, rdx);
31 }
32
33 public BigInteger(byte[] bval) throws NumberFormatException {
34 peer = new TBigInteger(bval);
35 }
36
37 BigInteger(TBigInteger peer) {
38 this.peer = peer;
39 }
40
41
42 public BigInteger(int sign, byte[] mag) throws NumberFormatException {
43 peer = new TBigInteger(sign, mag);
44 }
45
46 public BigInteger(int numBits, Random rnd) throws IllegalArgumentException {
47 peer = new TBigInteger(numBits, rnd);
48
49 }
50
51 public BigInteger(int bitLength, int certainty, Random rnd) throws ArithmeticException {
52 peer = new TBigInteger(bitLength, certainty, rnd);
53 }
54
55 //
56 // bitLen(val) is the number of bits in val.
57 //
58 static int bitLen(int w) {
59 // Binary search - decision tree (5 tests, rarely 6)
60 return (w < 1 << 15 ? (w < 1 << 7
61 ? (w < 1 << 3 ? (w < 1 << 1
62 ? (w < 1 << 0 ? (w < 0 ? 32 : 0) : 1)
63 : (w < 1 << 2 ? 2 : 3)) : (w < 1 << 5
64 ? (w < 1 << 4 ? 4 : 5)
65 : (w < 1 << 6 ? 6 : 7)))
66 : (w < 1 << 11
67 ? (w < 1 << 9 ? (w < 1 << 8 ? 8 : 9) : (w < 1 << 10 ? 10 : 11))

Callers

nothing calls this directly

Calls 1

valueOfMethod · 0.95

Tested by

no test coverage detected