Table of Content

    Java abs() Method : Find Absolute Value of Decimal MathContext


    Java - Find Absolute Value of Decimal :

    Returns a BigDecimal whose value is the absolute value of this BigDecimal, with rounding according to the context settings.

    Declaration

    Parameters

    Parameters
    mc the context to use.

    Return Value

    BigDecimal This method returns the absolute value of the called value i.e abs(this) rounded as necessary.

    Exception

    ArithmeticException if the result is inexact but the rounding mode is UNNECESSARY.

    Example

    Below is the example for the math.BigDecimal.abs() method.

    Output :