Documentation of 'com.google.common.primitives.UnsignedLong' Java class
UnsignedLong
com.google.common.primitives

Class UnsignedLong

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<UnsignedLong>


    @GwtCompatible(serializable=true)
    public final class UnsignedLong
    extends java.lang.Number
    implements java.lang.Comparable<UnsignedLong>, java.io.Serializable
    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
    See Also:
    Serialized Form
    • Method Detail

      • asUnsigned

        @Deprecated
         @Beta
        public static UnsignedLong asUnsigned(long value)
        Deprecated. Use fromLongBits(long). This method is scheduled to be removed in Guava release 15.0.
        Returns an 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.

      • fromLongBits

        public static UnsignedLong fromLongBits(long bits)
        Returns an 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.

        Since:
        14.0
      • valueOf

        public static UnsignedLong valueOf(long value)
        Returns an UnsignedLong representing the same value as the specified long.
        Throws:
        java.lang.IllegalArgumentException - if value is negative
        Since:
        14.0
      • valueOf

        public static UnsignedLong valueOf(java.math.BigInteger value)
        Returns a UnsignedLong representing the same value as the specified BigInteger. This is the inverse operation of bigIntegerValue().
        Throws:
        java.lang.IllegalArgumentException - if value is negative or value >= 2^64
      • valueOf

        public static UnsignedLong valueOf(java.lang.String string)
        Returns an UnsignedLong holding the value of the specified String, parsed as an unsigned long value.
        Throws:
        java.lang.NumberFormatException - if the string does not contain a parsable unsigned long value
      • valueOf

        public 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.
        Throws:
        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
      • add

        @Deprecated
         @Beta
        public UnsignedLong add(UnsignedLong val)
        Deprecated. Use plus(UnsignedLong). This method is scheduled to be removed in Guava release 15.0.
        Returns the result of adding this and val. If the result would have more than 64 bits, returns the low 64 bits of the result.
      • plus

        public UnsignedLong plus(UnsignedLong val)
        Returns the result of adding this and val. If the result would have more than 64 bits, returns the low 64 bits of the result.
        Since:
        14.0
      • subtract

        @Deprecated
         @Beta
        public UnsignedLong subtract(UnsignedLong val)
        Deprecated. Use minus(UnsignedLong). This method is scheduled to be removed in Guava release 15.0.
        Returns the result of subtracting this and val. If the result would be negative, returns the low 64 bits of the result.
      • minus

        public UnsignedLong minus(UnsignedLong val)
        Returns the result of subtracting this and val. If the result would have more than 64 bits, returns the low 64 bits of the result.
        Since:
        14.0
      • multiply

        @Deprecated
         @Beta
        public UnsignedLong multiply(UnsignedLong val)
        Deprecated. Use times(UnsignedLong). This method is scheduled to be removed in Guava release 15.0.
        Returns the result of multiplying this and val. If the result would have more than 64 bits, returns the low 64 bits of the result.
      • times

        @CheckReturnValue
        public UnsignedLong times(UnsignedLong val)
        Returns the result of multiplying this and val. If the result would have more than 64 bits, returns the low 64 bits of the result.
        Since:
        14.0
      • dividedBy

        @CheckReturnValue
        public UnsignedLong dividedBy(UnsignedLong val)
        Returns the result of dividing this by val.
        Since:
        14.0
      • intValue

        public int intValue()
        Returns the value of this UnsignedLong as an int.
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Returns the value of this 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.

        Specified by:
        longValue in class java.lang.Number
      • floatValue

        public float floatValue()
        Returns the value of this UnsignedLong as a float, analogous to a widening primitive conversion from long to float, and correctly rounded.
        Specified by:
        floatValue in class java.lang.Number
      • doubleValue

        public double doubleValue()
        Returns the value of this UnsignedLong as a double, analogous to a widening primitive conversion from long to double, and correctly rounded.
        Specified by:
        doubleValue in class java.lang.Number
      • bigIntegerValue

        public java.math.BigInteger bigIntegerValue()
        Returns the value of this UnsignedLong as a BigInteger.
      • compareTo

        public int compareTo(UnsignedLong o)
        Specified by:
        compareTo in interface java.lang.Comparable<UnsignedLong>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string representation of the UnsignedLong value, in base 10.
        Overrides:
        toString in class java.lang.Object
      • toString

        public java.lang.String toString(int radix)
        Returns a string representation of the UnsignedLong value, in base radix. If radix < Character.MIN_RADIX or radix > Character.MAX_RADIX, the radix 10 is used.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.