123 lines
3.7 KiB
Java
123 lines
3.7 KiB
Java
package com.google.common.primitives;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import java.io.Serializable;
|
|
import java.math.BigInteger;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class UnsignedLong extends Number implements Comparable<UnsignedLong>, Serializable {
|
|
private static final long UNSIGNED_MASK = Long.MAX_VALUE;
|
|
private final long value;
|
|
public static final UnsignedLong ZERO = new UnsignedLong(0);
|
|
public static final UnsignedLong ONE = new UnsignedLong(1);
|
|
public static final UnsignedLong MAX_VALUE = new UnsignedLong(-1);
|
|
|
|
private UnsignedLong(long j) {
|
|
this.value = j;
|
|
}
|
|
|
|
public static UnsignedLong fromLongBits(long j) {
|
|
return new UnsignedLong(j);
|
|
}
|
|
|
|
public static UnsignedLong valueOf(long j) {
|
|
Preconditions.a(j >= 0, "value (%s) is outside the range for an unsigned long value", j);
|
|
return fromLongBits(j);
|
|
}
|
|
|
|
public BigInteger bigIntegerValue() {
|
|
BigInteger valueOf = BigInteger.valueOf(this.value & UNSIGNED_MASK);
|
|
return this.value < 0 ? valueOf.setBit(63) : valueOf;
|
|
}
|
|
|
|
public UnsignedLong dividedBy(UnsignedLong unsignedLong) {
|
|
long j = this.value;
|
|
Preconditions.a(unsignedLong);
|
|
return fromLongBits(UnsignedLongs.b(j, unsignedLong.value));
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public double doubleValue() {
|
|
long j = this.value;
|
|
double d = UNSIGNED_MASK & j;
|
|
return j < 0 ? d + 9.223372036854776E18d : d;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
return (obj instanceof UnsignedLong) && this.value == ((UnsignedLong) obj).value;
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public float floatValue() {
|
|
long j = this.value;
|
|
float f = UNSIGNED_MASK & j;
|
|
return j < 0 ? f + 9.223372E18f : f;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Longs.a(this.value);
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public int intValue() {
|
|
return (int) this.value;
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public long longValue() {
|
|
return this.value;
|
|
}
|
|
|
|
public UnsignedLong minus(UnsignedLong unsignedLong) {
|
|
long j = this.value;
|
|
Preconditions.a(unsignedLong);
|
|
return fromLongBits(j - unsignedLong.value);
|
|
}
|
|
|
|
public UnsignedLong mod(UnsignedLong unsignedLong) {
|
|
long j = this.value;
|
|
Preconditions.a(unsignedLong);
|
|
return fromLongBits(UnsignedLongs.c(j, unsignedLong.value));
|
|
}
|
|
|
|
public UnsignedLong plus(UnsignedLong unsignedLong) {
|
|
long j = this.value;
|
|
Preconditions.a(unsignedLong);
|
|
return fromLongBits(j + unsignedLong.value);
|
|
}
|
|
|
|
public UnsignedLong times(UnsignedLong unsignedLong) {
|
|
long j = this.value;
|
|
Preconditions.a(unsignedLong);
|
|
return fromLongBits(j * unsignedLong.value);
|
|
}
|
|
|
|
public String toString() {
|
|
return UnsignedLongs.b(this.value);
|
|
}
|
|
|
|
@Override // java.lang.Comparable
|
|
public int compareTo(UnsignedLong unsignedLong) {
|
|
Preconditions.a(unsignedLong);
|
|
return UnsignedLongs.a(this.value, unsignedLong.value);
|
|
}
|
|
|
|
public String toString(int i) {
|
|
return UnsignedLongs.a(this.value, i);
|
|
}
|
|
|
|
public static UnsignedLong valueOf(BigInteger bigInteger) {
|
|
Preconditions.a(bigInteger);
|
|
Preconditions.a(bigInteger.signum() >= 0 && bigInteger.bitLength() <= 64, "value (%s) is outside the range for an unsigned long value", bigInteger);
|
|
return fromLongBits(bigInteger.longValue());
|
|
}
|
|
|
|
public static UnsignedLong valueOf(String str) {
|
|
return valueOf(str, 10);
|
|
}
|
|
|
|
public static UnsignedLong valueOf(String str, int i) {
|
|
return fromLongBits(UnsignedLongs.a(str, i));
|
|
}
|
|
}
|