what-the-bank/sources/com/google/common/primitives/UnsignedLong.java

113 lines
3.8 KiB
Java

package com.google.common.primitives;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.math.BigInteger;
/* loaded from: classes2.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.checkArgument(j >= 0, "value (%s) is outside the range for an unsigned long value", j);
return fromLongBits(j);
}
public static UnsignedLong valueOf(BigInteger bigInteger) {
Preconditions.checkNotNull(bigInteger);
Preconditions.checkArgument(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.parseUnsignedLong(str, i));
}
public final UnsignedLong plus(UnsignedLong unsignedLong) {
return fromLongBits(this.value + ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
}
public final UnsignedLong minus(UnsignedLong unsignedLong) {
return fromLongBits(this.value - ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
}
public final UnsignedLong times(UnsignedLong unsignedLong) {
return fromLongBits(this.value * ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
}
public final UnsignedLong dividedBy(UnsignedLong unsignedLong) {
return fromLongBits(UnsignedLongs.divide(this.value, ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value));
}
public final UnsignedLong mod(UnsignedLong unsignedLong) {
return fromLongBits(UnsignedLongs.remainder(this.value, ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value));
}
public final BigInteger bigIntegerValue() {
BigInteger valueOf = BigInteger.valueOf(this.value & Long.MAX_VALUE);
return this.value < 0 ? valueOf.setBit(63) : valueOf;
}
@Override // java.lang.Comparable
public final int compareTo(UnsignedLong unsignedLong) {
Preconditions.checkNotNull(unsignedLong);
return UnsignedLongs.compare(this.value, unsignedLong.value);
}
public final int hashCode() {
return Longs.hashCode(this.value);
}
public final boolean equals(Object obj) {
return (obj instanceof UnsignedLong) && this.value == ((UnsignedLong) obj).value;
}
public final String toString() {
return UnsignedLongs.toString(this.value);
}
public final String toString(int i) {
return UnsignedLongs.toString(this.value, i);
}
@Override // java.lang.Number
public final long longValue() {
return this.value;
}
@Override // java.lang.Number
public final int intValue() {
return (int) this.value;
}
@Override // java.lang.Number
public final float floatValue() {
long j = this.value;
float f = (float) (Long.MAX_VALUE & j);
return j < 0 ? f + 9.223372E18f : f;
}
@Override // java.lang.Number
public final double doubleValue() {
long j = this.value;
double d = Long.MAX_VALUE & j;
return j < 0 ? d + 9.223372036854776E18d : d;
}
}