Decimal arithmetic
Copyright (c) IBM Corporation, 2000. All rights reserved. © | 11 Jan 2000 |
[previous | contents | next] |
public final class MathContext implements java.lang.Serializable |
The MathContext immutable class encapsulates the settings understood by the BigDecimal class for the arithmetic operator methods. The operator methods are those that effect an operation on a number or a pair of numbers.
At present, the settings comprise the number of digits (precision) to be used for an operation, the form of any exponent that results from the operation, whether checking for lost digits is enabled, and the algorithm to be used for rounding.
When provided, a MathContext object supplies the settings for an operation directly; when MathContext.DEFAULT is provided then the default settings are used ("digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP").
All methods which accept a MathContext object (or null, implying the defaults) also have a version of the method that will not accept a MathContext object. These versions carry out fixed point arithmetic with unlimited precision (as though the settings were: "digits=0 form=PLAIN lostDigits=0 roundingMode=ROUND_HALF_UP").