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.
BigDecimalRoundingModeprecision > 0 and
precision <= MAX_LOOKASIDE. In this case they will share the
BigInteger int[] array. Note that the transients
cannot be final because they are reconstructed on
deserialization.
MathContext with the specified
precision and the HALF_UP rounding
mode.
setPrecision The non-negative int precision setting.java.lang.IllegalArgumentException if the setPrecision parameter is less
than zero.MathContext with a specified
precision and rounding mode.
setPrecision The non-negative int precision setting.setRoundingMode The rounding mode to use.java.lang.IllegalArgumentException if the setPrecision parameter is less
than zero.java.lang.NullPointerException if the rounding mode argument is nullMathContext from a string.
The string must be in the same format as that produced by the
toString() method.
An IllegalArgumentException is thrown if the precision
section of the string is out of range (< 0) or the string is
not in the format created by the method.
toString()
val The string to be parsedjava.lang.IllegalArgumentException if the precision section is out of range
or of incorrect formatjava.lang.NullPointerException if the argument is nullRoundingMode.CEILING,
RoundingMode.DOWN,
RoundingMode.FLOOR,
RoundingMode.HALF_DOWN,
RoundingMode.HALF_EVEN,
RoundingMode.HALF_UP,
RoundingMode.UNNECESSARY, or
RoundingMode.UP.
RoundingMode object which is the value of the
roundingMode settingMathContext.
The String returned represents the settings of the
MathContext object as two space-delimited words
(separated by a single space character, '\u0020',
and with no leading or trailing white space), as follows:
"precision=", immediately followed
by the value of the precision setting as a numeric string as if
generated by the Integer.toString
method.
"roundingMode=", immediately
followed by the value of the roundingMode setting as a
word. This word will be the same as the name of the
corresponding public constant in the RoundingMode
enum.
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.
String representing the context settings