@Beta @GwtCompatible(serializable=true) public final class UnsignedLong extends Number implements Comparable<UnsignedLong>, Serializable
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.
Modifier and Type | Field and Description |
---|---|
static UnsignedLong |
MAX_VALUE |
static UnsignedLong |
ONE |
static UnsignedLong |
ZERO |
Modifier and Type | Method and Description |
---|---|
UnsignedLong |
add(UnsignedLong val)
Returns the result of adding this and
val . |
static UnsignedLong |
asUnsigned(long value)
Returns an
UnsignedLong that, when treated as signed, is equal to value . |
BigInteger |
bigIntegerValue()
Returns the value of this
UnsignedLong as a BigInteger . |
int |
compareTo(UnsignedLong o) |
UnsignedLong |
divide(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(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. |
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 |
multiply(UnsignedLong val)
Returns the result of multiplying this and
val . |
UnsignedLong |
remainder(UnsignedLong val)
Returns the remainder of dividing this by
val . |
UnsignedLong |
subtract(UnsignedLong val)
Returns the result of subtracting this and
val . |
String |
toString()
Returns a string representation of the
UnsignedLong value, in base 10. |
String |
toString(int radix)
Returns a string representation of the
UnsignedLong value, in base radix . |
static UnsignedLong |
valueOf(BigInteger value)
Returns a
UnsignedLong representing the same value as the specified BigInteger
. |
static UnsignedLong |
valueOf(String string)
Returns an
UnsignedLong holding the value of the specified String , parsed as
an unsigned long value. |
static UnsignedLong |
valueOf(String string,
int radix)
Returns an
UnsignedLong holding the value of the specified String , parsed as
an unsigned long value in the specified radix. |
byteValue, shortValue
public static final UnsignedLong ZERO
public static final UnsignedLong ONE
public static final UnsignedLong MAX_VALUE
public static UnsignedLong asUnsigned(long value)
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 valueOf(BigInteger value)
UnsignedLong
representing the same value as the specified BigInteger
. This is the inverse operation of bigIntegerValue()
.IllegalArgumentException
- if value
is negative or value >= 2^64
public static UnsignedLong valueOf(String string)
UnsignedLong
holding the value of the specified String
, parsed as
an unsigned long
value.NumberFormatException
- if the string does not contain a parsable unsigned long
valuepublic static UnsignedLong valueOf(String string, int radix)
UnsignedLong
holding the value of the specified String
, parsed as
an unsigned long
value in the specified radix.NumberFormatException
- if the string does not contain a parsable unsigned long
value, or radix
is not between Character.MIN_RADIX
and
Character.MAX_RADIX
public UnsignedLong add(UnsignedLong val)
val
. If the result would have more than 64 bits,
returns the low 64 bits of the result.public UnsignedLong subtract(UnsignedLong val)
val
. If the result would be negative,
returns the low 64 bits of the result.public UnsignedLong multiply(UnsignedLong val)
val
. If the result would have more than 64
bits, returns the low 64 bits of the result.public UnsignedLong divide(UnsignedLong val)
val
.public UnsignedLong remainder(UnsignedLong val)
val
.public int intValue()
UnsignedLong
as an int
.public 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
.
public float floatValue()
UnsignedLong
as a float
, analogous to a widening
primitive conversion from long
to float
, and correctly rounded.floatValue
in class Number
public double doubleValue()
UnsignedLong
as a double
, analogous to a widening
primitive conversion from long
to double
, and correctly rounded.doubleValue
in class Number
public BigInteger bigIntegerValue()
UnsignedLong
as a BigInteger
.public int compareTo(UnsignedLong o)
compareTo
in interface Comparable<UnsignedLong>
public String toString()
UnsignedLong
value, in base 10.public String toString(int radix)
UnsignedLong
value, in base radix
. If
radix < Character.MIN_RADIX
or radix > Character.MAX_RADIX
, the radix
10
is used.Copyright © 2013 Seam Framework. All Rights Reserved.