Class Decimal128

    • Constructor Summary

      Constructors 
      Constructor Description
      Decimal128​(long value)
      Constructs a Decimal128 value representing the given long.
      Decimal128​(BigDecimal value)
      Constructs a Decimal128 value representing the given BigDecimal.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BigDecimal bigDecimalValue​()
      Gets a BigDecimal that is equivalent to this Decimal128.
      boolean equals​(Object o)
      Returns true if the encoded representation of this instance is the same as the encoded representation of o.
      static Decimal128 fromIEEE754BIDEncoding​(long high, long low)
      Create an instance with the given high and low order bits representing this Decimal128 as an IEEE 754-2008 128-bit decimal floating point using the BID encoding scheme.
      long getHigh​()
      Gets the high-order 64 bits of the IEEE 754-2008 128-bit decimal floating point encoding for this Decimal128, using the BID encoding scheme.
      long getLow​()
      Gets the low-order 64 bits of the IEEE 754-2008 128-bit decimal floating point encoding for this Decimal128, using the BID encoding scheme.
      int hashCode​()  
      boolean isFinite​()
      Returns true if this Decimal128 is finite.
      boolean isInfinite​()
      Returns true if this Decimal128 is infinite.
      boolean isNaN​()
      Returns true if this Decimal128 is Not-A-Number (NaN).
      boolean isNegative​()
      Returns true if this Decimal128 is negative.
      static Decimal128 parse​(String value)
      Returns a Decimal128 value representing the given String.
      String toString​()
      Returns the String representation of the Decimal128 value.
    • Field Detail

      • POSITIVE_INFINITY

        public static final Decimal128 POSITIVE_INFINITY
        A constant holding the positive infinity of type Decimal128. It is equal to the value return by Decimal128.valueOf("Infinity").
      • NEGATIVE_INFINITY

        public static final Decimal128 NEGATIVE_INFINITY
        A constant holding the negative infinity of type Decimal128. It is equal to the value return by Decimal128.valueOf("-Infinity").
      • NEGATIVE_NaN

        public static final Decimal128 NEGATIVE_NaN
        A constant holding a negative Not-a-Number (-NaN) value of type Decimal128. It is equal to the value return by Decimal128.valueOf("-NaN").
      • NaN

        public static final Decimal128 NaN
        A constant holding a Not-a-Number (NaN) value of type Decimal128. It is equal to the value return by Decimal128.valueOf("NaN").
      • POSITIVE_ZERO

        public static final Decimal128 POSITIVE_ZERO
        A constant holding a postive zero value of type Decimal128. It is equal to the value return by Decimal128.valueOf("0").
      • NEGATIVE_ZERO

        public static final Decimal128 NEGATIVE_ZERO
        A constant holding a negative zero value of type Decimal128. It is equal to the value return by Decimal128.valueOf("-0").
    • Constructor Detail

      • Decimal128

        public Decimal128​(long value)
        Constructs a Decimal128 value representing the given long.
        Parameters:
        value - the Decimal128 value represented as a long
      • Decimal128

        public Decimal128​(BigDecimal value)
        Constructs a Decimal128 value representing the given BigDecimal.
        Parameters:
        value - the Decimal128 value represented as a BigDecimal
        Throws:
        NumberFormatException - if the value is out of the Decimal128 range
    • Method Detail

      • parse

        public static Decimal128 parse​(String value)
        Returns a Decimal128 value representing the given String.
        Parameters:
        value - the Decimal128 value represented as a String
        Returns:
        the Decimal128 value representing the given String
        Throws:
        NumberFormatException - if the value is out of the Decimal128 range
        See Also:
        From-String Specification
      • fromIEEE754BIDEncoding

        public static Decimal128 fromIEEE754BIDEncoding​(long high,
                                                        long low)
        Create an instance with the given high and low order bits representing this Decimal128 as an IEEE 754-2008 128-bit decimal floating point using the BID encoding scheme.
        Parameters:
        high - the high-order 64 bits
        low - the low-order 64 bits
        Returns:
        the Decimal128 value representing the given high and low order bits
      • getHigh

        public long getHigh​()
        Gets the high-order 64 bits of the IEEE 754-2008 128-bit decimal floating point encoding for this Decimal128, using the BID encoding scheme.
        Returns:
        the high-order 64 bits of this Decimal128
      • getLow

        public long getLow​()
        Gets the low-order 64 bits of the IEEE 754-2008 128-bit decimal floating point encoding for this Decimal128, using the BID encoding scheme.
        Returns:
        the low-order 64 bits of this Decimal128
      • bigDecimalValue

        public BigDecimal bigDecimalValue​()
        Gets a BigDecimal that is equivalent to this Decimal128.
        Returns:
        a BigDecimal that is equivalent to this Decimal128
        Throws:
        ArithmeticException - if the Decimal128 value is NaN, Infinity, -Infinity, or -0, none of which can be represented as a BigDecimal
      • isNegative

        public boolean isNegative​()
        Returns true if this Decimal128 is negative.
        Returns:
        true if this Decimal128 is negative
      • isInfinite

        public boolean isInfinite​()
        Returns true if this Decimal128 is infinite.
        Returns:
        true if this Decimal128 is infinite
      • isFinite

        public boolean isFinite​()
        Returns true if this Decimal128 is finite.
        Returns:
        true if this Decimal128 is finite
      • isNaN

        public boolean isNaN​()
        Returns true if this Decimal128 is Not-A-Number (NaN).
        Returns:
        true if this Decimal128 is Not-A-Number
      • equals

        public boolean equals​(Object o)
        Returns true if the encoded representation of this instance is the same as the encoded representation of o.

        One consequence is that, whereas Double.NaN != Double.NaN, new Decimal128("NaN").equals(new Decimal128("NaN") returns true.

        Another consequence is that, as with BigDecimal, new Decimal128("1.0").equals(new Decimal128("1.00") returns false, because the precision is not the same and therefore the representation is not the same.

        Overrides:
        equals in class Object
        Parameters:
        o - the object to compare for equality
        Returns:
        true if the instances are equal
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class Object