Decimal arithmetic
Copyright (c) IBM Corporation, 2000. All rights reserved. © | 11 Jan 2000 |
[previous | contents | next] |
A MathContext object whose settings have their default values.
The default values of the settings are: "digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP"
A constant of type int that signifies that standard floating point notation (with engineering exponential format, where the power of ten is a multiple of 3, if needed) should be used for the result of a BigDecimal operation.
A constant of type int that signifies that plain (fixed point) notation, without any exponent, should be used for the result of a BigDecimal operation. A zero result in plain form may have a decimal part of one or more zeros.
A constant of type int that signifies that standard floating point notation (with scientific exponential format, where there is one digit before any decimal point, if needed) should be used for the result of a BigDecimal operation.
The remaining constants indicate rounding algorithms. Rounding is applied when a result needs more digits of precision than are available; in this case the digit to the left of the first discarded digit may be incremented or decremented, depending on the rounding algorithm selected.[1]
A constant of type int that signifies that if any of the discarded digits are non-zero then the result should be rounded towards the next more positive digit.
A constant of type int that signifies that all discarded digits are ignored (truncated). The result is neither incremented nor decremented.
A constant of type int that signifies that if any of the discarded digits are non-zero then the result should be rounded towards the next more negative digit.
A constant of type int that signifies that if the discarded digits represent greater than half (0.5) the value of a one in the next position then the result should be rounded up (away from zero). Otherwise the discarded digits are ignored.
A constant of type int that signifies that if the discarded digits represent greater than half (0.5) the value of a one in the next position then the result should be rounded up (away from zero). If they represent less than half, then the result should be rounded down.
Otherwise (they represent exactly half) the result is rounded down if its rightmost digit is even, or rounded up if its rightmost digit is odd (to make an even digit).
A constant of type int that signifies that if the discarded digits represent greater than or equal to half (0.5) the value of a one in the next position then the result should be rounded up (away from zero). Otherwise the discarded digits are ignored.
A constant of type int that signifies that rounding (potential loss of information) is not permitted. If any of the discarded digits are non-zero then an ArithmeticException should be thrown.
A constant of type int that signifies that if any of the discarded digits are non-zero then the result will be rounded up (away from zero).
A value of type int that describes the number of digits (precision) to be used for a BigDecimal operation. A value of 0 indicates that unlimited precision (as many digits as are required) fixed-scale arithmetic will be used.
The BigDecimal operator methods use this value to determine the precision of results. Note that leading zeros (in the integer part of a number) are never significant. digits will always be non-negative.
A value of type int that describes the format of results from a BigDecimal operation. The BigDecimal operator methods use this value to determine the formatting of results. form will be ENGINEERING, PLAIN, or SCIENTIFIC.
A value of type boolean that is true if checking for lost digits is enabled, or is false otherwise. The BigDecimal operator methods use this value to determine whether checking for lost digits should take place.
A value of type int that describes the rounding algorithm to be used for a BigDecimal operation. The BigDecimal operator methods use this value to determine the algorithm to be used when non-zero digits have to be discarded in order to reduce the precision of a result. roundingMode will have the value of one of the public constants whose name starts with ROUND_.
[1] | These constants have the same values as the constants of the same name in java.math.BigDecimal, which have been preserved to maintain compatibility with earlier versions of BigDecimal. |