mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-05 20:09:49 +01:00
123 lines
4 KiB
Java
123 lines
4 KiB
Java
package com.google.common.primitives;
|
|
|
|
import com.google.common.annotations.GwtCompatible;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
|
import java.math.BigInteger;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@GwtCompatible(serializable = true)
|
|
/* loaded from: classes8.dex */
|
|
public final class UnsignedLong extends Number implements Comparable<UnsignedLong> {
|
|
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);
|
|
}
|
|
|
|
@CanIgnoreReturnValue
|
|
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 BigInteger bigIntegerValue() {
|
|
BigInteger valueOf = BigInteger.valueOf(this.value & Long.MAX_VALUE);
|
|
return this.value < 0 ? valueOf.setBit(63) : valueOf;
|
|
}
|
|
|
|
@Override // java.lang.Comparable
|
|
public int compareTo(UnsignedLong unsignedLong) {
|
|
Preconditions.checkNotNull(unsignedLong);
|
|
return UnsignedLongs.compare(this.value, unsignedLong.value);
|
|
}
|
|
|
|
public UnsignedLong dividedBy(UnsignedLong unsignedLong) {
|
|
return fromLongBits(UnsignedLongs.divide(this.value, ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value));
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public double doubleValue() {
|
|
long j = this.value;
|
|
if (j >= 0) {
|
|
return j;
|
|
}
|
|
return ((j & 1) | (j >>> 1)) * 2.0d;
|
|
}
|
|
|
|
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;
|
|
if (j >= 0) {
|
|
return j;
|
|
}
|
|
return ((j & 1) | (j >>> 1)) * 2.0f;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return Longs.hashCode(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) {
|
|
return fromLongBits(this.value - ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
|
|
}
|
|
|
|
public UnsignedLong mod(UnsignedLong unsignedLong) {
|
|
return fromLongBits(UnsignedLongs.remainder(this.value, ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value));
|
|
}
|
|
|
|
public UnsignedLong plus(UnsignedLong unsignedLong) {
|
|
return fromLongBits(this.value + ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
|
|
}
|
|
|
|
public UnsignedLong times(UnsignedLong unsignedLong) {
|
|
return fromLongBits(this.value * ((UnsignedLong) Preconditions.checkNotNull(unsignedLong)).value);
|
|
}
|
|
|
|
public String toString() {
|
|
return UnsignedLongs.toString(this.value);
|
|
}
|
|
|
|
public String toString(int i) {
|
|
return UnsignedLongs.toString(this.value, i);
|
|
}
|
|
|
|
@CanIgnoreReturnValue
|
|
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);
|
|
}
|
|
|
|
@CanIgnoreReturnValue
|
|
public static UnsignedLong valueOf(String str) {
|
|
return valueOf(str, 10);
|
|
}
|
|
|
|
@CanIgnoreReturnValue
|
|
public static UnsignedLong valueOf(String str, int i) {
|
|
return fromLongBits(UnsignedLongs.parseUnsignedLong(str, i));
|
|
}
|
|
}
|