BigDecimal that can represent negative zeros.
The primary change is the addition of isNegativeZero().Warning
This class should not be extended by code outside of this library.
This class currently does not have any behavioral difference
from BigDecimal except for the following:
toString(), toEngineeringString(), and
toPlainString() print a negative sign if necessary.
floatValue() and doubleValue() return negative zero
results.
abs does the right thing.
equals or compareTo
so those methods cannot distinguish positive and negative zeros.
It also does not currently override any of the numerical methods,
but it may do so in the future. If you are concerned about
consistent treatment of negative zeros in future releases, you may wish to
use bigDecimalValue before performing those operations.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final Decimal | NEGATIVE_ZERO
The value -0, with a scale of 0. |
| private static final long | |
| public static final Decimal | ZERO
Hides java. |
| Access | Constructor and Description |
|---|---|
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static BigDecimal | Returns: null if the given value is null.may be null. val)Returns a "plain" |
| public final BigDecimal | bigDecimalValue()
Converts this to a "plain" |
| public static boolean | equals(BigDecimal v1, BigDecimal v2)
Compares two decimal values for equality, observing both precision and negative zeros. |
| public static boolean | Returns: true if and only if the value is a negative zero.Efficiently determines whether an arbitary decimal value is a negative zero. |
| public final boolean | |
| public static Decimal | negativeZero(int
the number of significant digits (zeros) after the decimal
point. scale)Returns a negative-zero decimal value, with the given number of significant digits (zeros). |
| public static Decimal | negativeZero(int
the number of significant digits (zeros) after the decimal
point. scale, MathContext mc)Returns a negative-zero decimal value, with the given number of significant digits (zeros) and given context. |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | valueOf(long
value of the val)BigDecimal.Hides java. Translates a |
| public static Decimal | |
| public static Decimal | valueOf(double
double to convert to a BigDecimal.Hides java. Translates a |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal | |
| public static Decimal |
| NEGATIVE_ZERO | back to summary |
|---|---|
| public static final Decimal NEGATIVE_ZERO The value -0, with a scale of 0. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ZERO | back to summary |
|---|---|
| public static final Decimal ZERO Hides java. The value 0, with a scale of 0. | |
| Decimal | back to summary |
|---|---|
| private Decimal(BigInteger unscaledVal, int scale) | |
| Decimal | back to summary |
|---|---|
| private Decimal(BigInteger unscaledVal, int scale, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(BigInteger val) | |
| Decimal | back to summary |
|---|---|
| private Decimal(BigInteger val, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(int val) | |
| Decimal | back to summary |
|---|---|
| private Decimal(int val, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(long val) | |
| Decimal | back to summary |
|---|---|
| private Decimal(long val, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(double val) | |
| Decimal | back to summary |
|---|---|
| private Decimal(double val, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(char[] in, int offset, int len) | |
| Decimal | back to summary |
|---|---|
| private Decimal(char[] in, int offset, int len, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(char[] in) | |
| Decimal | back to summary |
|---|---|
| private Decimal(char[] in, MathContext mc) | |
| Decimal | back to summary |
|---|---|
| private Decimal(String val) | |
| Decimal | back to summary |
|---|---|
| private Decimal(String val, MathContext mc) | |
| bigDecimalValue | back to summary |
|---|---|
| public static BigDecimal bigDecimalValue(BigDecimal val) Returns a "plain"
| |
| bigDecimalValue | back to summary |
|---|---|
| public final BigDecimal bigDecimalValue() Converts this to a "plain"
| |
| equals | back to summary |
|---|---|
| public static boolean equals(BigDecimal v1, BigDecimal v2) Compares two decimal values for equality, observing both precision and
negative zeros. This differs from
| |
| isNegativeZero | back to summary |
|---|---|
| public static boolean isNegativeZero(BigDecimal val) Efficiently determines whether an arbitary decimal value is a negative
zero. This can only be true when the value is actually a
| |
| isNegativeZero | back to summary |
|---|---|
| public final boolean isNegativeZero() | |
| negativeZero | back to summary |
|---|---|
| public static Decimal negativeZero(int scale) Returns a negative-zero decimal value, with the given number of significant digits (zeros).
| |
| negativeZero | back to summary |
|---|---|
| public static Decimal negativeZero(int scale, MathContext mc) Returns a negative-zero decimal value, with the given number of significant digits (zeros) and given context.
| |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigInteger unscaledVal, int scale) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigInteger unscaledVal, int scale, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigInteger val) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigInteger val, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(int val) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(int val, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(long val) Hides java. Doc from java. Translates a
| |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(long val, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(double val) Hides java. Doc from java. Translates a
| |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(double val, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigDecimal val) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(BigDecimal val, MathContext mc) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(String val) | |
| valueOf | back to summary |
|---|---|
| public static Decimal valueOf(String val, MathContext mc) | |
| Modifier and Type | Field and Description |
|---|---|
| private static final long |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public BigDecimal | abs()
Overrides java. Returns a |
| public BigDecimal | abs(MathContext
the context to use. mc)Overrides java. Returns a |
| public double | |
| public float | |
| public String | toEngineeringString()
Overrides java. Returns a string representation of this |
| public String | toPlainString()
Overrides java. Returns a string representation of this |
| public String | toString()
Overrides java. Returns the string representation of this |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| NegativeZero | back to summary |
|---|---|
| private NegativeZero(int scale) | |
| NegativeZero | back to summary |
|---|---|
| private NegativeZero(int scale, MathContext mc) | |
| abs | back to summary |
|---|---|
| public BigDecimal abs() Overrides java. Doc from java. Returns a
| |
| abs | back to summary |
|---|---|
| public BigDecimal abs(MathContext mc) Overrides java. Doc from java. Returns a
| |
| doubleValue | back to summary |
|---|---|
| public double doubleValue() Overrides java. Doc from java. Converts this
| |
| floatValue | back to summary |
|---|---|
| public float floatValue() Overrides java. Doc from java. Converts this
| |
| toEngineeringString | back to summary |
|---|---|
| public String toEngineeringString() Overrides java. Doc from java. Returns a string representation of this Returns a string that represents the | |
| toPlainString | back to summary |
|---|---|
| public String toPlainString() Overrides java. Doc from java. Returns a string representation of this | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the string representation of this A standard canonical string form of the Next, an adjusted exponent is calculated; this is the
negated scale, plus the number of characters in the converted
unscaled value, less one. That is,
If the scale is greater than or equal to zero and the
adjusted exponent is greater than or equal to Otherwise (that is, if the scale is negative, or the
adjusted exponent is less than Finally, the entire string is prefixed by a minus sign
character Examples: For each representation [unscaled value, scale] on the left, the resulting string is shown on the right. [123,0] "123" [-123,0] "-123" [123,-1] "1.23E+3" [123,-3] "1.23E+5" [123,1] "12.3" [123,5] "0.00123" [123,10] "1.23E-8" [-123,12] "-1.23E-10"Notes:
| |