java.io.Serializable, java.lang.Comparablepublic class Decimal
extends java.lang.Number
implements java.lang.Comparable
Decimal encodes a number as
an array of bytes in base-100 and a signed exponent (-64 to +63).
The byte array is of fixed size with the implied decimal point to the
left of the first byte. The exponent represents powers of 100. A special
exponent value DECPOSNULL indicates a Decimal
with null (undefined) value.| Modifier and Type | Field | Description |
|---|---|---|
static int |
DECPOSNULL |
Exponent value indicating a null
Decimal, i.e., a Decimal
with undefined value. |
static int |
DECSIZE |
Size of the array of bytes representing the digits of the
Decimal. |
| Modifier and Type | Method | Description |
|---|---|---|
java.math.BigDecimal |
bigDecimalValue() |
Converts the
Decimal to a BigDecimal value. |
byte |
byteValue() |
Converts the
Decimal to a byte value. |
int |
compareTo(java.lang.Object other) |
Compares this
Decimal object to another object. |
int |
compareTo(Decimal other) |
Compares two
Decimal objects numerically. |
byte[] |
digits() |
Returns the actual decimal digits.
|
double |
doubleValue() |
Converts the
Decimal to a double value. |
boolean |
equals(java.lang.Object obj) |
Compares this object to another object.
|
int |
exponent() |
Returns the exponent of the
Decimal value. |
float |
floatValue() |
Converts the
Decimal to a float value. |
int |
intValue() |
Converts the
Decimal to an int value. |
long |
longValue() |
Converts the
Decimal to a long value. |
Decimal |
negate() |
Creates a newly allocated
Decimal whose value is (-this). |
int |
numDigits() |
Returns the number of significant digits in the
Decimal value. |
short |
shortValue() |
Converts the
Decimal to a short value. |
int |
sign() |
Returns the sign of the
Decimal value. |
java.lang.String |
toString() |
Converts the
Decimal to a String. |
static java.lang.String |
toString(Decimal dec) |
Converts the input
Decimal to a String. |
static Decimal |
valueOf(java.lang.String s) |
Constructs a newly allocated
Decimal object from a String value. |
public static final int DECSIZE
Decimal.public static final int DECPOSNULL
Decimal, i.e., a Decimal
with undefined value. Null Decimals cannot be compared numerically
with other Decimals.public int exponent()
Decimal value. The exponent
represents powers of 100.public int sign()
Decimal value.DECPOSNULL a null value.DECPOSNULLpublic int numDigits()
Decimal value.Decimal value.public byte[] digits()
public Decimal negate()
Decimal whose value is (-this).Decimal whose value is (-this). If the original Decimal
has a null value, that is, its sign is DECPOSNULL, a new null Decimal is returned.DECPOSNULLpublic java.math.BigDecimal bigDecimalValue()
Decimal to a BigDecimal value.BigDecimal value representing the Decimal. If
the Decimal has a null value, a new BigDecimal(Double.MIN_VALUE)
is returned.public double doubleValue()
Decimal to a double value.doubleValue in class java.lang.Numberdouble value representing the Decimal. If
the Decimal has a null value, Double.MIN_VALUE
is returned.public float floatValue()
throws java.lang.NumberFormatException
Decimal to a float value.floatValue in class java.lang.Numberfloat value representing the Decimal. If
the Decimal has a null value, Float.MIN_VALUE
is returned.java.lang.NumberFormatException - if the Decimal value would cause overflow
when converted to a float.public long longValue()
throws java.lang.NumberFormatException
Decimal to a long value.longValue in class java.lang.Numberlong value representing the Decimal. If
the Decimal has a null value, Long.MIN_VALUE
is returned.java.lang.NumberFormatException - if the Decimal value cannot be
represented as a long.public int intValue()
throws java.lang.NumberFormatException
Decimal to an int value.intValue in class java.lang.Numberint value representing the Decimal. If
the Decimal has a null value, Integer.MIN_VALUE
is returned.java.lang.NumberFormatException - if the Decimal value cannot be
represented as an int.public short shortValue()
throws java.lang.NumberFormatException
Decimal to a short value.shortValue in class java.lang.Numbershort value representing the Decimal. If
the Decimal has a null value, Short.MIN_VALUE
is returned.java.lang.NumberFormatException - if the Decimal value cannot be
represented as a short.public byte byteValue()
throws java.lang.NumberFormatException
Decimal to a byte value.byteValue in class java.lang.Numberbyte value representing the Decimal. If
the Decimal has a null value, Byte.MIN_VALUE
is returned.java.lang.NumberFormatException - if the Decimal value cannot be
represented as a byte.public java.lang.String toString()
throws java.lang.NumberFormatException
Decimal to a String. The String is
in the format that the Java Double.toString method would
generate for an equivalent double value.toString in class java.lang.ObjectString value representing the Decimal.java.lang.NumberFormatException - if the Decimal value cannot be
represented as a double.public static java.lang.String toString(Decimal dec) throws java.lang.NumberFormatException
Decimal to a String. The String is
in the format that the Java Double.toString method would
generate for an equivalent double value.dec - the Decimal object to convert.String value representing the Decimal.java.lang.NumberFormatException - if the Decimal value cannot be
represented as a double.public static Decimal valueOf(java.lang.String s) throws java.lang.NumberFormatException
Decimal object from a String value. The String
is converted to a Decimal value. The String must be in the format accepted
by the Java Double.parseDouble method.s - the String value to convert.java.lang.NumberFormatException - if the value is in the wrong format or
would overflow or underflow when converted to Decimal.public int compareTo(java.lang.Object other)
throws java.lang.NumberFormatException
Decimal object to another object. If the
other object is a Decimal, this function behaves like
compareTo(Decimal). Otherwise, it throws a ClassCastException.compareTo in interface java.lang.Comparableother - the other object to comparejava.lang.ClassCastException - if obj is not a Decimaljava.lang.NumberFormatException - if either of the objects has a null value,
that is, if their exponent is equal to DECPOSNULL.DECPOSNULLpublic int compareTo(Decimal other) throws java.lang.NumberFormatException
Decimal objects numerically. Neither
object can have a null value.other - a Decimal that is compared against this
object.java.lang.NumberFormatException - if either of the objects has a null value,
that is, if their exponent is equal to DECPOSNULL.DECPOSNULLpublic boolean equals(java.lang.Object obj)
Decimal
object with the same value as the current object. The values are
equal if the objects have identical bit patterns. Note that null
valued Decimals may be compared in this operation
(unlike compareTo(Decimal)).equals in class java.lang.Objectobj - the other object to compareDecimal
with the same value as the current object.