Uses of Class
java.math.MathContext
Packages that use MathContext
Package
Description
Provides classes for performing arbitrary-precision integer
arithmetic (
BigInteger) and arbitrary-precision decimal
arithmetic (BigDecimal).-
Uses of MathContext in java.math
Fields in java.math declared as MathContextModifier and TypeFieldDescriptionstatic final MathContextMathContext.DECIMAL128AMathContextobject with a precision setting matching the precision of the IEEE 754-2019 decimal128 format, 34 digits, and a rounding mode ofHALF_EVEN.static final MathContextMathContext.DECIMAL32AMathContextobject with a precision setting matching the precision of the IEEE 754-2019 decimal32 format, 7 digits, and a rounding mode ofHALF_EVEN.static final MathContextMathContext.DECIMAL64AMathContextobject with a precision setting matching the precision of the IEEE 754-2019 decimal64 format, 16 digits, and a rounding mode ofHALF_EVEN.static final MathContextMathContext.UNLIMITEDAMathContextobject whose settings have the values required for unlimited precision arithmetic.Methods in java.math with parameters of type MathContextModifier and TypeMethodDescriptionBigDecimal.abs(MathContext mc) Returns aBigDecimalwhose value is the absolute value of thisBigDecimal, with rounding according to the context settings.BigDecimal.add(BigDecimal augend, MathContext mc) Returns aBigDecimalwhose value is(this + augend), with rounding according to the context settings.BigDecimal.divide(BigDecimal divisor, MathContext mc) Returns aBigDecimalwhose value is(this / divisor), with rounding according to the context settings.BigDecimal.divideAndRemainder(BigDecimal divisor, MathContext mc) Returns a two-elementBigDecimalarray containing the result ofdivideToIntegralValuefollowed by the result ofremainderon the two operands calculated with rounding according to the context settings.BigDecimal.divideToIntegralValue(BigDecimal divisor, MathContext mc) Returns aBigDecimalwhose value is the integer part of(this / divisor).BigDecimal.multiply(BigDecimal multiplicand, MathContext mc) Returns aBigDecimalwhose value is(this × multiplicand), with rounding according to the context settings.BigDecimal.negate(MathContext mc) Returns aBigDecimalwhose value is(-this), with rounding according to the context settings.BigDecimal.plus(MathContext mc) Returns aBigDecimalwhose value is(+this), with rounding according to the context settings.BigDecimal.pow(int n, MathContext mc) Returns aBigDecimalwhose value is(thisn).BigDecimal.remainder(BigDecimal divisor, MathContext mc) Returns aBigDecimalwhose value is(this % divisor), with rounding according to the context settings.BigDecimal.round(MathContext mc) Returns aBigDecimalrounded according to theMathContextsettings.BigDecimal.sqrt(MathContext mc) Returns an approximation to the square root ofthiswith rounding according to the context settings.BigDecimal.subtract(BigDecimal subtrahend, MathContext mc) Returns aBigDecimalwhose value is(this - subtrahend), with rounding according to the context settings.Constructors in java.math with parameters of type MathContextModifierConstructorDescriptionBigDecimal(char[] in, int offset, int len, MathContext mc) Translates a character array representation of aBigDecimalinto aBigDecimal, accepting the same sequence of characters as theBigDecimal(String)constructor, while allowing a sub-array to be specified and with rounding according to the context settings.BigDecimal(char[] in, MathContext mc) Translates a character array representation of aBigDecimalinto aBigDecimal, accepting the same sequence of characters as theBigDecimal(String)constructor and with rounding according to the context settings.BigDecimal(double val, MathContext mc) Translates adoubleinto aBigDecimal, with rounding according to the context settings.BigDecimal(int val, MathContext mc) Translates anintinto aBigDecimal, with rounding according to the context settings.BigDecimal(long val, MathContext mc) Translates alonginto aBigDecimal, with rounding according to the context settings.BigDecimal(String val, MathContext mc) Translates the string representation of aBigDecimalinto aBigDecimal, accepting the same strings as theBigDecimal(String)constructor, with rounding according to the context settings.BigDecimal(BigInteger unscaledVal, int scale, MathContext mc) Translates aBigIntegerunscaled value and anintscale into aBigDecimal, with rounding according to the context settings.BigDecimal(BigInteger val, MathContext mc) Translates aBigIntegerinto aBigDecimalrounding according to the context settings.