MCPcopy Index your code
hub / github.com/clojure/clojure / BigInt

Class BigInt

src/jvm/clojure/lang/BigInt.java:18–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16import java.math.BigDecimal;
17
18public final class BigInt extends Number implements IHashEq{
19
20private static final long serialVersionUID = 5097771279236135022L;
21
22final public long lpart;
23final public BigInteger bipart;
24
25final public static BigInt ZERO = new BigInt(0,null);
26final public static BigInt ONE = new BigInt(1,null);
27
28
29//must follow Long
30public int hashCode(){
31 if(bipart == null)
32 return (int) (this.lpart ^ (this.lpart >>> 32));
33 return bipart.hashCode();
34}
35
36public int hasheq(){
37 if(bipart == null)
38 return Murmur3.hashLong(lpart);
39 return bipart.hashCode();
40
41}
42
43public boolean equals(Object obj){
44 if(this == obj)
45 return true;
46 if(obj instanceof BigInt)
47 {
48 BigInt o = (BigInt) obj;
49 if(bipart == null)
50 return o.bipart == null && this.lpart == o.lpart;
51 return o.bipart != null && this.bipart.equals(o.bipart);
52 }
53 return false;
54}
55
56private BigInt(long lpart, BigInteger bipart){
57 this.lpart = lpart;
58 this.bipart = bipart;
59}
60
61public static BigInt fromBigInteger(BigInteger val){
62 if(val.bitLength() < 64)
63 return new BigInt(val.longValue(), null);
64 else
65 return new BigInt(0, val);
66}
67
68public static BigInt fromLong(long val){
69 return new BigInt(val, null);
70}
71
72public BigInteger toBigInteger(){
73 if(bipart == null)
74 return BigInteger.valueOf(lpart);
75 else

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected