mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-05 20:09:49 +01:00
112 lines
3.8 KiB
Java
112 lines
3.8 KiB
Java
package com.google.common.primitives;
|
|
|
|
import com.google.common.annotations.GwtCompatible;
|
|
import com.google.common.annotations.GwtIncompatible;
|
|
import com.google.common.annotations.J2ktIncompatible;
|
|
import com.google.common.base.Preconditions;
|
|
import java.math.BigInteger;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
@GwtCompatible(emulated = true)
|
|
/* loaded from: classes8.dex */
|
|
public final class UnsignedInteger extends Number implements Comparable<UnsignedInteger> {
|
|
private final int value;
|
|
public static final UnsignedInteger ZERO = fromIntBits(0);
|
|
public static final UnsignedInteger ONE = fromIntBits(1);
|
|
public static final UnsignedInteger MAX_VALUE = fromIntBits(-1);
|
|
|
|
private UnsignedInteger(int i) {
|
|
this.value = i;
|
|
}
|
|
|
|
public static UnsignedInteger fromIntBits(int i) {
|
|
return new UnsignedInteger(i);
|
|
}
|
|
|
|
public static UnsignedInteger valueOf(BigInteger bigInteger) {
|
|
Preconditions.checkNotNull(bigInteger);
|
|
Preconditions.checkArgument(bigInteger.signum() >= 0 && bigInteger.bitLength() <= 32, "value (%s) is outside the range for an unsigned integer value", bigInteger);
|
|
return fromIntBits(bigInteger.intValue());
|
|
}
|
|
|
|
public BigInteger bigIntegerValue() {
|
|
return BigInteger.valueOf(longValue());
|
|
}
|
|
|
|
@Override // java.lang.Comparable
|
|
public int compareTo(UnsignedInteger unsignedInteger) {
|
|
Preconditions.checkNotNull(unsignedInteger);
|
|
return UnsignedInts.compare(this.value, unsignedInteger.value);
|
|
}
|
|
|
|
public UnsignedInteger dividedBy(UnsignedInteger unsignedInteger) {
|
|
return fromIntBits(UnsignedInts.divide(this.value, ((UnsignedInteger) Preconditions.checkNotNull(unsignedInteger)).value));
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public double doubleValue() {
|
|
return longValue();
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
return (obj instanceof UnsignedInteger) && this.value == ((UnsignedInteger) obj).value;
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public float floatValue() {
|
|
return longValue();
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.value;
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public int intValue() {
|
|
return this.value;
|
|
}
|
|
|
|
@Override // java.lang.Number
|
|
public long longValue() {
|
|
return UnsignedInts.toLong(this.value);
|
|
}
|
|
|
|
public UnsignedInteger minus(UnsignedInteger unsignedInteger) {
|
|
return fromIntBits(this.value - ((UnsignedInteger) Preconditions.checkNotNull(unsignedInteger)).value);
|
|
}
|
|
|
|
public UnsignedInteger mod(UnsignedInteger unsignedInteger) {
|
|
return fromIntBits(UnsignedInts.remainder(this.value, ((UnsignedInteger) Preconditions.checkNotNull(unsignedInteger)).value));
|
|
}
|
|
|
|
public UnsignedInteger plus(UnsignedInteger unsignedInteger) {
|
|
return fromIntBits(this.value + ((UnsignedInteger) Preconditions.checkNotNull(unsignedInteger)).value);
|
|
}
|
|
|
|
@J2ktIncompatible
|
|
@GwtIncompatible
|
|
public UnsignedInteger times(UnsignedInteger unsignedInteger) {
|
|
return fromIntBits(this.value * ((UnsignedInteger) Preconditions.checkNotNull(unsignedInteger)).value);
|
|
}
|
|
|
|
public String toString() {
|
|
return toString(10);
|
|
}
|
|
|
|
public String toString(int i) {
|
|
return UnsignedInts.toString(this.value, i);
|
|
}
|
|
|
|
public static UnsignedInteger valueOf(long j) {
|
|
Preconditions.checkArgument((4294967295L & j) == j, "value (%s) is outside the range for an unsigned integer value", j);
|
|
return fromIntBits((int) j);
|
|
}
|
|
|
|
public static UnsignedInteger valueOf(String str) {
|
|
return valueOf(str, 10);
|
|
}
|
|
|
|
public static UnsignedInteger valueOf(String str, int i) {
|
|
return fromIntBits(UnsignedInts.parseUnsignedInt(str, i));
|
|
}
|
|
}
|