Uses of Class
java.math.MathContext

Packages that useMathContext
Package
Description
java.math
Provides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal).
  • Uses ofMathContext injava.math

    Fields injava.math declared asMathContext
    Modifier and Type
    Field
    Description
    static finalMathContext
    MathContext.DECIMAL128
    AMathContext object with a precision setting matching the precision of the IEEE 754-2019 decimal128 format, 34 digits, and a rounding mode ofHALF_EVEN.
    static finalMathContext
    MathContext.DECIMAL32
    AMathContext object with a precision setting matching the precision of the IEEE 754-2019 decimal32 format, 7 digits, and a rounding mode ofHALF_EVEN.
    static finalMathContext
    MathContext.DECIMAL64
    AMathContext object with a precision setting matching the precision of the IEEE 754-2019 decimal64 format, 16 digits, and a rounding mode ofHALF_EVEN.
    static finalMathContext
    MathContext.UNLIMITED
    AMathContext object whose settings have the values required for unlimited precision arithmetic.
    Methods injava.math with parameters of typeMathContext
    Modifier and Type
    Method
    Description
    BigDecimal.abs(MathContext mc)
    Returns aBigDecimal whose value is the absolute value of thisBigDecimal, with rounding according to the context settings.
    BigDecimal.add(BigDecimal augend,MathContext mc)
    Returns aBigDecimal whose value is(this + augend), with rounding according to the context settings.
    BigDecimal.divide(BigDecimal divisor,MathContext mc)
    Returns aBigDecimal whose value is(this / divisor), with rounding according to the context settings.
    BigDecimal.divideAndRemainder(BigDecimal divisor,MathContext mc)
    Returns a two-elementBigDecimal array containing the result ofdivideToIntegralValue followed by the result ofremainder on the two operands calculated with rounding according to the context settings.
    Returns aBigDecimal whose value is the integer part of(this / divisor).
    BigDecimal.multiply(BigDecimal multiplicand,MathContext mc)
    Returns aBigDecimal whose value is(this × multiplicand), with rounding according to the context settings.
    BigDecimal.negate(MathContext mc)
    Returns aBigDecimal whose value is(-this), with rounding according to the context settings.
    BigDecimal.plus(MathContext mc)
    Returns aBigDecimal whose value is(+this), with rounding according to the context settings.
    BigDecimal.pow(int n,MathContext mc)
    Returns aBigDecimal whose value is(thisn).
    BigDecimal.remainder(BigDecimal divisor,MathContext mc)
    Returns aBigDecimal whose value is(this % divisor), with rounding according to the context settings.
    BigDecimal.round(MathContext mc)
    Returns aBigDecimal rounded according to theMathContext settings.
    BigDecimal.sqrt(MathContext mc)
    Returns an approximation to the square root ofthis with rounding according to the context settings.
    BigDecimal.subtract(BigDecimal subtrahend,MathContext mc)
    Returns aBigDecimal whose value is(this - subtrahend), with rounding according to the context settings.
    Constructors injava.math with parameters of typeMathContext
    Modifier
    Constructor
    Description
     
    BigDecimal(char[] in, int offset, int len,MathContext mc)
    Translates a character array representation of aBigDecimal into 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 aBigDecimal into 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 adouble into aBigDecimal, with rounding according to the context settings.
     
    BigDecimal(int val,MathContext mc)
    Translates anint into aBigDecimal, with rounding according to the context settings.
     
    BigDecimal(long val,MathContext mc)
    Translates along into aBigDecimal, with rounding according to the context settings.
     
    Translates the string representation of aBigDecimal into aBigDecimal, accepting the same strings as theBigDecimal(String) constructor, with rounding according to the context settings.
     
    BigDecimal(BigInteger unscaledVal, int scale,MathContext mc)
    Translates aBigInteger unscaled value and anint scale into aBigDecimal, with rounding according to the context settings.
     
    Translates aBigInteger into aBigDecimal rounding according to the context settings.