public final class Decimal128 extends java.lang.Number implements java.lang.Comparable<Decimal128>
Modifier and Type | Field and Description |
---|---|
static Decimal128 |
NaN
A constant holding a Not-a-Number (NaN) value of type
Decimal128 . |
static Decimal128 |
NEGATIVE_INFINITY
A constant holding the negative infinity of type
Decimal128 . |
static Decimal128 |
NEGATIVE_NaN
A constant holding a negative Not-a-Number (-NaN) value of type
Decimal128 . |
static Decimal128 |
NEGATIVE_ZERO
A constant holding a negative zero value of type
Decimal128 . |
static Decimal128 |
POSITIVE_INFINITY
A constant holding the positive infinity of type
Decimal128 . |
static Decimal128 |
POSITIVE_ZERO
A constant holding a postive zero value of type
Decimal128 . |
Constructor and Description |
---|
Decimal128(java.math.BigDecimal value)
Constructs a Decimal128 value representing the given BigDecimal.
|
Decimal128(long value)
Constructs a Decimal128 value representing the given long.
|
Modifier and Type | Method and Description |
---|---|
java.math.BigDecimal |
bigDecimalValue()
Gets a BigDecimal that is equivalent to this Decimal128.
|
int |
compareTo(Decimal128 o) |
double |
doubleValue()
Converts this
Decimal128 to a double . |
boolean |
equals(java.lang.Object o)
Returns true if the encoded representation of this instance is the same as the encoded representation of
o . |
float |
floatValue()
Converts this
Decimal128 to a float . |
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() |
int |
intValue()
Converts this
Decimal128 to a int . |
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.
|
long |
longValue()
Converts this
Decimal128 to a long . |
static Decimal128 |
parse(java.lang.String value)
Returns a Decimal128 value representing the given String.
|
java.lang.String |
toString()
Returns the String representation of the Decimal128 value.
|
public static final Decimal128 POSITIVE_INFINITY
Decimal128
. It is equal to the value return by
Decimal128.valueOf("Infinity")
.public static final Decimal128 NEGATIVE_INFINITY
Decimal128
. It is equal to the value return by
Decimal128.valueOf("-Infinity")
.public static final Decimal128 NEGATIVE_NaN
Decimal128
. It is equal to the value return by
Decimal128.valueOf("-NaN")
.public static final Decimal128 NaN
Decimal128
. It is equal to the value return by
Decimal128.valueOf("NaN")
.public static final Decimal128 POSITIVE_ZERO
Decimal128
. It is equal to the value return by
Decimal128.valueOf("0")
.public static final Decimal128 NEGATIVE_ZERO
Decimal128
. It is equal to the value return by
Decimal128.valueOf("-0")
.public Decimal128(long value)
value
- the Decimal128 value represented as a longpublic Decimal128(java.math.BigDecimal value)
value
- the Decimal128 value represented as a BigDecimaljava.lang.NumberFormatException
- if the value is out of the Decimal128 rangepublic static Decimal128 parse(java.lang.String value)
value
- the Decimal128 value represented as a Stringjava.lang.NumberFormatException
- if the value is out of the Decimal128 rangepublic static Decimal128 fromIEEE754BIDEncoding(long high, long low)
high
- the high-order 64 bitslow
- the low-order 64 bitspublic long getHigh()
public long getLow()
public java.math.BigDecimal bigDecimalValue()
java.lang.ArithmeticException
- if the Decimal128 value is NaN, Infinity, -Infinity, or -0, none of which can be represented as a
BigDecimalpublic boolean isNegative()
public boolean isInfinite()
public boolean isFinite()
public boolean isNaN()
public int compareTo(Decimal128 o)
compareTo
in interface java.lang.Comparable<Decimal128>
public int intValue()
Decimal128
to a int
. This conversion is analogous to the narrowing primitive conversion from
double
to int
as defined in The Java™ Language Specification: any fractional part of this
Decimal128
will be discarded, and if the resulting integral value is too big to fit in a int
, only the
low-order 32 bits are returned. Note that this conversion can lose information about the overall magnitude and precision of this
Decimal128
value as well as return a result with the opposite sign. Note that #NEGATIVE_ZERO
is converted to
0
.intValue
in class java.lang.Number
Decimal128
converted to a int
.public long longValue()
Decimal128
to a long
. This conversion is analogous to the narrowing primitive conversion from
double
to long
as defined in The Java™ Language Specification: any fractional part of this
Decimal128
will be discarded, and if the resulting integral value is too big to fit in a long
, only the
low-order 64 bits are returned. Note that this conversion can lose information about the overall magnitude and precision of this
Decimal128
value as well as return a result with the opposite sign. Note that #NEGATIVE_ZERO
is converted to
0L
.longValue
in class java.lang.Number
Decimal128
converted to a long
.public float floatValue()
Decimal128
to a float
. This conversion is similar to the narrowing primitive conversion from
double
to float
as defined in The Java™ Language Specification: if this Decimal128
has
too great a magnitude to represent as a float
, it will be converted to Float.NEGATIVE_INFINITY
or
Float.POSITIVE_INFINITY
as appropriate. Note that even when the return value is finite, this conversion can lose
information about the precision of the Decimal128
value. Note that #NEGATIVE_ZERO
is converted to 0.0f
.floatValue
in class java.lang.Number
Decimal128
converted to a float
.public double doubleValue()
Decimal128
to a double
. This conversion is similar to the narrowing primitive conversion from
double
to float
as defined in The Java™ Language Specification: if this Decimal128
has
too great a magnitude to represent as a double
, it will be converted to Double.NEGATIVE_INFINITY
or
Double.POSITIVE_INFINITY
as appropriate. Note that even when the return value is finite, this conversion can lose
information about the precision of the Decimal128
value. Note that #NEGATIVE_ZERO
is converted to 0.0d
.doubleValue
in class java.lang.Number
Decimal128
converted to a double
.public boolean equals(java.lang.Object o)
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.
equals
in class java.lang.Object
o
- the object to compare for equalitypublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2010 - 2023 Adobe. All Rights Reserved