|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
com.google.common.primitives.UnsignedLong
@GwtCompatible(serializable=true) public final class UnsignedLong
A wrapper class for unsigned long values, supporting arithmetic operations.
In some cases, when speed is more important than code readability, it may be faster simply to
treat primitive long values as unsigned, using the methods from UnsignedLongs.
See the Guava User Guide article on unsigned primitive utilities.
| Field Summary | |
|---|---|
static UnsignedLong |
MAX_VALUE
|
static UnsignedLong |
ONE
|
static UnsignedLong |
ZERO
|
| Method Summary | |
|---|---|
UnsignedLong |
add(UnsignedLong val)
Deprecated. Use plus(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0. |
static UnsignedLong |
asUnsigned(long value)
Deprecated. Use fromLongBits(long). This method is scheduled to be removed in Guava
release 15.0. |
java.math.BigInteger |
bigIntegerValue()
Returns the value of this UnsignedLong as a BigInteger. |
int |
compareTo(UnsignedLong o)
|
UnsignedLong |
divide(UnsignedLong val)
Deprecated. Use dividedBy(UnsignedLong). This method is scheduled to be removed in
Guava release 15.0. |
UnsignedLong |
dividedBy(UnsignedLong val)
Returns the result of dividing this by val. |
double |
doubleValue()
Returns the value of this UnsignedLong as a double, analogous to a widening
primitive conversion from long to double, and correctly rounded. |
boolean |
equals(java.lang.Object obj)
|
float |
floatValue()
Returns the value of this UnsignedLong as a float, analogous to a widening
primitive conversion from long to float, and correctly rounded. |
static UnsignedLong |
fromLongBits(long bits)
Returns an UnsignedLong corresponding to a given bit representation. |
int |
hashCode()
|
int |
intValue()
Returns the value of this UnsignedLong as an int. |
long |
longValue()
Returns the value of this UnsignedLong as a long. |
UnsignedLong |
minus(UnsignedLong val)
Returns the result of subtracting this and val. |
UnsignedLong |
mod(UnsignedLong val)
Returns this modulo val. |
UnsignedLong |
multiply(UnsignedLong val)
Deprecated. Use times(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0. |
UnsignedLong |
plus(UnsignedLong val)
Returns the result of adding this and val. |
UnsignedLong |
remainder(UnsignedLong val)
Deprecated. Use mod(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0. |
UnsignedLong |
subtract(UnsignedLong val)
Deprecated. Use minus(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0. |
UnsignedLong |
times(UnsignedLong val)
Returns the result of multiplying this and val. |
java.lang.String |
toString()
Returns a string representation of the UnsignedLong value, in base 10. |
java.lang.String |
toString(int radix)
Returns a string representation of the UnsignedLong value, in base radix. |
static UnsignedLong |
valueOf(java.math.BigInteger value)
Returns a UnsignedLong representing the same value as the specified
BigInteger. |
static UnsignedLong |
valueOf(long value)
Returns an UnsignedLong representing the same value as the specified long. |
static UnsignedLong |
valueOf(java.lang.String string)
Returns an UnsignedLong holding the value of the specified String, parsed as
an unsigned long value. |
static UnsignedLong |
valueOf(java.lang.String string,
int radix)
Returns an UnsignedLong holding the value of the specified String, parsed as
an unsigned long value in the specified radix. |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final UnsignedLong ZERO
public static final UnsignedLong ONE
public static final UnsignedLong MAX_VALUE
| Method Detail |
|---|
@Deprecated @Beta public static UnsignedLong asUnsigned(long value)
fromLongBits(long). This method is scheduled to be removed in Guava
release 15.0.
UnsignedLong that, when treated as signed, is equal to value. The
inverse operation is longValue().
Put another way, if value is negative, the returned result will be equal to
2^64 + value; otherwise, the returned result will be equal to value.
public static UnsignedLong fromLongBits(long bits)
UnsignedLong corresponding to a given bit representation.
The argument is interpreted as an unsigned 64-bit value. Specifically, the sign bit
of bits is interpreted as a normal bit, and all other bits are treated as usual.
If the argument is nonnegative, the returned result will be equal to bits,
otherwise, the result will be equal to 2^64 + bits.
To represent decimal constants less than 2^63, consider valueOf(long)
instead.
public static UnsignedLong valueOf(long value)
UnsignedLong representing the same value as the specified long.
java.lang.IllegalArgumentException - if value is negativepublic static UnsignedLong valueOf(java.math.BigInteger value)
UnsignedLong representing the same value as the specified
BigInteger. This is the inverse operation of bigIntegerValue().
java.lang.IllegalArgumentException - if value is negative or value >= 2^64public static UnsignedLong valueOf(java.lang.String string)
UnsignedLong holding the value of the specified String, parsed as
an unsigned long value.
java.lang.NumberFormatException - if the string does not contain a parsable unsigned long
value
public static UnsignedLong valueOf(java.lang.String string,
int radix)
UnsignedLong holding the value of the specified String, parsed as
an unsigned long value in the specified radix.
java.lang.NumberFormatException - if the string does not contain a parsable unsigned long
value, or radix is not between Character.MIN_RADIX and
Character.MAX_RADIX@Deprecated @Beta public UnsignedLong add(UnsignedLong val)
plus(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0.
val. If the result would have more than 64 bits,
returns the low 64 bits of the result.
public UnsignedLong plus(UnsignedLong val)
val. If the result would have more than 64 bits,
returns the low 64 bits of the result.
@Deprecated @Beta public UnsignedLong subtract(UnsignedLong val)
minus(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0.
val. If the result would be negative,
returns the low 64 bits of the result.
public UnsignedLong minus(UnsignedLong val)
val. If the result would have more than 64
bits, returns the low 64 bits of the result.
@Deprecated @Beta public UnsignedLong multiply(UnsignedLong val)
times(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0.
val. If the result would have more than 64
bits, returns the low 64 bits of the result.
@CheckReturnValue public UnsignedLong times(UnsignedLong val)
val. If the result would have more than 64
bits, returns the low 64 bits of the result.
@Deprecated @Beta public UnsignedLong divide(UnsignedLong val)
dividedBy(UnsignedLong). This method is scheduled to be removed in
Guava release 15.0.
val.
@CheckReturnValue public UnsignedLong dividedBy(UnsignedLong val)
val.
@Deprecated @Beta public UnsignedLong remainder(UnsignedLong val)
mod(UnsignedLong). This method is scheduled to be removed in Guava
release 15.0.
val.
@CheckReturnValue public UnsignedLong mod(UnsignedLong val)
val.
public int intValue()
UnsignedLong as an int.
intValue in class java.lang.Numberpublic long longValue()
UnsignedLong as a long. This is an inverse operation
to asUnsigned(long).
Note that if this UnsignedLong holds a value >= 2^63, the returned value
will be equal to this - 2^64.
longValue in class java.lang.Numberpublic float floatValue()
UnsignedLong as a float, analogous to a widening
primitive conversion from long to float, and correctly rounded.
floatValue in class java.lang.Numberpublic double doubleValue()
UnsignedLong as a double, analogous to a widening
primitive conversion from long to double, and correctly rounded.
doubleValue in class java.lang.Numberpublic java.math.BigInteger bigIntegerValue()
UnsignedLong as a BigInteger.
public int compareTo(UnsignedLong o)
compareTo in interface java.lang.Comparable<UnsignedLong>public int hashCode()
hashCode in class java.lang.Object
public boolean equals(@Nullable
java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
UnsignedLong value, in base 10.
toString in class java.lang.Objectpublic java.lang.String toString(int radix)
UnsignedLong value, in base radix. If
radix < Character.MIN_RADIX or radix > Character.MAX_RADIX, the radix
10 is used.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||