Class UnsignedLong
java.lang.Object
java.lang.Number
com.google.common.primitives.UnsignedLong
- All Implemented Interfaces:
- Serializable,- Comparable<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.
- Since:
- 11.0
- Author:
- Louis Wasserman, Colin Evans
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final UnsignedLongstatic final UnsignedLongstatic final UnsignedLong
- 
Method SummaryModifier and TypeMethodDescriptionReturns the value of thisUnsignedLongas aBigInteger.intdividedBy(UnsignedLong val) Returns the result of dividing this byval.doubleReturns the value of thisUnsignedLongas adouble, analogous to a widening primitive conversion fromlongtodouble, and correctly rounded.booleanfloatReturns the value of thisUnsignedLongas afloat, analogous to a widening primitive conversion fromlongtofloat, and correctly rounded.static UnsignedLongfromLongBits(long bits) Returns anUnsignedLongcorresponding to a given bit representation.inthashCode()intintValue()Returns the value of thisUnsignedLongas anint.longReturns the value of thisUnsignedLongas along.minus(UnsignedLong val) Returns the result of subtracting this andval.mod(UnsignedLong val) Returns this moduloval.plus(UnsignedLong val) Returns the result of adding this andval.times(UnsignedLong val) Returns the result of multiplying this andval.toString()Returns a string representation of theUnsignedLongvalue, in base 10.toString(int radix) Returns a string representation of theUnsignedLongvalue, in baseradix.static UnsignedLongvalueOf(long value) Returns anUnsignedLongrepresenting the same value as the specifiedlong.static UnsignedLongReturns anUnsignedLongholding the value of the specifiedString, parsed as an unsignedlongvalue.static UnsignedLongReturns anUnsignedLongholding the value of the specifiedString, parsed as an unsignedlongvalue in the specified radix.static UnsignedLongvalueOf(BigInteger value) Returns aUnsignedLongrepresenting the same value as the specifiedBigInteger.Methods inherited from class java.lang.NumberbyteValue, shortValue
- 
Field Details- 
ZERO
- 
ONE
- 
MAX_VALUE
 
- 
- 
Method Details- 
fromLongBitsReturns anUnsignedLongcorresponding to a given bit representation. The argument is interpreted as an unsigned 64-bit value. Specifically, the sign bit ofbitsis 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 to2^64 + bits.To represent decimal constants less than 2^63, considervalueOf(long)instead.- Since:
- 14.0
 
- 
valueOfReturns anUnsignedLongrepresenting the same value as the specifiedlong.- Throws:
- IllegalArgumentException- if- valueis negative
- Since:
- 14.0
 
- 
valueOfReturns aUnsignedLongrepresenting the same value as the specifiedBigInteger. This is the inverse operation ofbigIntegerValue().- Throws:
- IllegalArgumentException- if- valueis negative or- value >= 2^64
 
- 
valueOfReturns anUnsignedLongholding the value of the specifiedString, parsed as an unsignedlongvalue.- Throws:
- NumberFormatException- if the string does not contain a parsable unsigned- longvalue
 
- 
valueOfReturns anUnsignedLongholding the value of the specifiedString, parsed as an unsignedlongvalue in the specified radix.- Throws:
- NumberFormatException- if the string does not contain a parsable unsigned- longvalue, or- radixis not between- Character.MIN_RADIXand- Character.MAX_RADIX
 
- 
plusReturns the result of adding this andval. If the result would have more than 64 bits, returns the low 64 bits of the result.- Since:
- 14.0
 
- 
minusReturns the result of subtracting this andval. If the result would have more than 64 bits, returns the low 64 bits of the result.- Since:
- 14.0
 
- 
timesReturns the result of multiplying this andval. If the result would have more than 64 bits, returns the low 64 bits of the result.- Since:
- 14.0
 
- 
dividedByReturns the result of dividing this byval.- Since:
- 14.0
 
- 
mod
- 
intValue
- 
longValuepublic long longValue()Returns the value of thisUnsignedLongas along. This is an inverse operation tofromLongBits(long).Note that if this UnsignedLongholds a value>= 2^63, the returned value will be equal tothis - 2^64.
- 
floatValuepublic float floatValue()Returns the value of thisUnsignedLongas afloat, analogous to a widening primitive conversion fromlongtofloat, and correctly rounded.- Specified by:
- floatValuein class- Number
 
- 
doubleValuepublic double doubleValue()Returns the value of thisUnsignedLongas adouble, analogous to a widening primitive conversion fromlongtodouble, and correctly rounded.- Specified by:
- doubleValuein class- Number
 
- 
bigIntegerValueReturns the value of thisUnsignedLongas aBigInteger.
- 
compareTo- Specified by:
- compareToin interface- Comparable<UnsignedLong>
 
- 
hashCode
- 
equals
- 
toString
- 
toStringReturns a string representation of theUnsignedLongvalue, in baseradix. Ifradix < Character.MIN_RADIXorradix > Character.MAX_RADIX, the radix10is used.
 
-