Class Decimal64

    • Constructor Detail

      • Decimal64

        protected Decimal64​(Decimal64 other)
    • Method Detail

      • of

        public static Decimal64 of​(int scale,
                                   long unscaledValue)
        Return a Decimal64 with specified scale and unscaled value.
        Parameters:
        scale - scale to use
        unscaledValue - unscaled value to use
        Returns:
        A Decimal64 instance
        Throws:
        IllegalArgumentException - if scale is not in range [1..18]
      • minValueIn

        public static Decimal64 minValueIn​(int scale)
        Return the minimum value supported in specified scale.
        Parameters:
        scale - scale to use
        Returns:
        Minimum value in that scale
        Throws:
        IllegalArgumentException - if scale is not in range [1..18]
      • maxValueIn

        public static Decimal64 maxValueIn​(int scale)
        Return the maximum value supported in specified scale.
        Parameters:
        scale - scale to use
        Returns:
        Maximum value in that scale
        Throws:
        IllegalArgumentException - if scale is not in range [1..18]
      • valueOf

        public static Decimal64 valueOf​(int scale,
                                        byte byteVal)
      • valueOf

        public static Decimal64 valueOf​(int scale,
                                        short shortVal)
      • valueOf

        public static Decimal64 valueOf​(int scale,
                                        int intVal)
      • valueOf

        public static Decimal64 valueOf​(int scale,
                                        long longVal)
      • valueOf

        public static Decimal64 valueOf​(String str)
        Attempt to parse a String into a Decimal64. This method uses minimum fraction digits required to hold the entire value.
        Parameters:
        str - String to parser
        Returns:
        A Decimal64 instance
        Throws:
        NullPointerException - if value is null.
        NumberFormatException - if the string does not contain a parsable decimal64.
      • scale

        public final int scale()
        Return the scale of this decimal. This is the number of fraction digits, in range [1..18].
        Returns:
        This decimal's scale
      • unscaledValue

        public final long unscaledValue()
        Return the unscaled value of this decimal.
        Returns:
        This decimal's unscaled value
      • decimalValue

        public final BigDecimal decimalValue()
      • intValue

        public final int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public final long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public final float floatValue()
        Specified by:
        floatValue in class Number
      • doubleValue

        public final double doubleValue()
        Specified by:
        doubleValue in class Number
      • byteValueExact

        public final byte byteValueExact()
        Converts this BigDecimal to a byte, checking for lost information. If this Decimal64 has a nonzero fractional part or is out of the possible range for a byte result then an ArithmeticException is thrown.
        Returns:
        this Decimal64 converted to a byte.
        Throws:
        ArithmeticException - if this has a nonzero fractional part, or will not fit in a byte.
      • shortValueExact

        public final short shortValueExact()
        Converts this BigDecimal to a short, checking for lost information. If this Decimal64 has a nonzero fractional part or is out of the possible range for a short result then an ArithmeticException is thrown.
        Returns:
        this Decimal64 converted to a short.
        Throws:
        ArithmeticException - if this has a nonzero fractional part, or will not fit in a short.
      • intValueExact

        public final int intValueExact()
        Converts this BigDecimal to an int, checking for lost information. If this Decimal64 has a nonzero fractional part or is out of the possible range for an int result then an ArithmeticException is thrown.
        Returns:
        this Decimal64 converted to an int.
        Throws:
        ArithmeticException - if this has a nonzero fractional part, or will not fit in an int.
      • longValueExact

        public final long longValueExact()
        Converts this BigDecimal to a long, checking for lost information. If this Decimal64 has a nonzero fractional part then an ArithmeticException is thrown.
        Returns:
        this Decimal64 converted to a long.
        Throws:
        ArithmeticException - if this has a nonzero fractional part.
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public final boolean equals​(@Nullable Object obj)
        Overrides:
        equals in class Object
      • equals

        public final boolean equals​(@Nullable Decimal64 obj)
        A slightly faster version of equals(Object).
        Parameters:
        obj - Decimal64 object
        Returns:
        true if this object is the same as the obj argument; false otherwise.