BigDecimal class.
The base-independent settings are:
precision:
the number of digits to be used for an operation; results are
rounded to this precision
roundingMode:
a RoundingMode object which specifies the algorithm to be
used for rounding.
BigDecimal, RoundingMode
| Modifier and Type | Field and Description |
|---|---|
| public static final MathContext | DECIMAL128
A |
| public static final MathContext | |
| public static final MathContext | |
| private static final RoundingMode | |
| private static final int | |
| pack-priv final int | precision
The number of digits to be used for an operation. |
| pack-priv final RoundingMode | roundingMode
The rounding algorithm to be used for an operation. |
| private static final long | |
| public static final MathContext | UNLIMITED
A |
| Access | Constructor and Description |
|---|---|
| public | MathContext(int
The non-negative setPrecision)int precision setting.Constructs a new |
| public | MathContext(int
The non-negative setPrecision, RoundingMode int precision setting.The rounding mode to use. setRoundingMode)Constructs a new |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if and only if the specified Object is
a MathContext object which has exactly the same
settings as this objectObject to which this MathContext is to
be compared.Overrides java. Compares this |
| public int | Returns: anint which is the value of the precision
settingReturns the |
| public RoundingMode | Returns: aRoundingMode object which is the value of the
roundingMode settingReturns the roundingMode setting. |
| public int | Returns: hash code for thisMathContextOverrides java. Returns the hash code for this |
| private void | readObject(ObjectInputStream
the stream being read. s)Reconstitute the |
| public String | Returns: aString representing the context settingsOverrides java. Returns the string representation of this |
| DECIMAL128 | back to summary |
|---|---|
| public static final MathContext DECIMAL128 A | |
| DECIMAL32 | back to summary |
|---|---|
| public static final MathContext DECIMAL32 A | |
| DECIMAL64 | back to summary |
|---|---|
| public static final MathContext DECIMAL64 A | |
| DEFAULT_ROUNDINGMODE | back to summary |
|---|---|
| private static final RoundingMode DEFAULT_ROUNDINGMODE | |
| MIN_DIGITS | back to summary |
|---|---|
| private static final int MIN_DIGITS | |
| precision | back to summary |
|---|---|
| pack-priv final int precision The number of digits to be used for an operation. A value of 0 indicates that unlimited precision (as many digits as are required) will be used. Note that leading zeros (in the coefficient of a number) are never significant.
| |
| roundingMode | back to summary |
|---|---|
| pack-priv final RoundingMode roundingMode The rounding algorithm to be used for an operation.
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID
| |
| UNLIMITED | back to summary |
|---|---|
| public static final MathContext UNLIMITED A | |
| MathContext | back to summary |
|---|---|
| public MathContext(int setPrecision) Constructs a new
| |
| MathContext | back to summary |
|---|---|
| public MathContext(int setPrecision, RoundingMode setRoundingMode) Constructs a new
| |
| MathContext | back to summary |
|---|---|
| public MathContext(String val) Constructs a new An
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object x) Overrides java. Compares this
| |
| getPrecision | back to summary |
|---|---|
| public int getPrecision() Returns the
| |
| getRoundingMode | back to summary |
|---|---|
| public RoundingMode getRoundingMode() Returns the roundingMode setting.
This will be one of
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code for this
| |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException Reconstitute the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns the string representation of this
For example: precision=9 roundingMode=HALF_UPAdditional words may be appended to the result of toString in the future if more properties are added to
this class.
| |