MathContext
immutable class encapsulates the settings understood by the operator methods of the {@link BigDecimal}class (and potentially other classes). Operator methods are those that effect an operation on a number or a pair of numbers. The settings, which are not base-dependent, comprise:
digits
: the number of digits (precision) to be used for an operation form
: the form of any exponent that results from the operation lostDigits
: whether checking for lost digits is enabled roundingMode
: the algorithm to be used for rounding. When provided, a MathContext
object supplies the settings for an operation directly.
When MathContext.DEFAULT
is provided for a MathContext
parameter then the default settings are used (9, SCIENTIFIC, false, ROUND_HALF_UP
).
In the BigDecimal
class, all methods which accept a MathContext
object defaults) also have a version of the method which does not accept a MathContext parameter. These versions carry out unlimited precision fixed point arithmetic (as though the settings were (0, PLAIN, false, ROUND_HALF_UP
).
The instance variables are shared with default access (so they are directly accessible to the BigDecimal
class), but must never be changed.
The rounding mode constants have the same names and values as the constants of the same name in java.math.BigDecimal
, to maintain compatibility with earlier versions of BigDecimal
.
@see BigDecimal
@author Mike Cowlishaw
@stable ICU 2.0
|
|
|
|
|
|
|
|
|
|
|
|