![]() |
VOOZH | about |
public BigDecimal negate()Parameters: The method does not take any parameters . Return Value: This method returns the negative value of the BigDecimal object and whose scale is this.scale(). Below programs will illustrate the use of java.math.BigDecimal.negate() function: Program 1 :
Negated value is -4743
Negated value is 9674283517.97
public BigDecimal negate(MathContext mc)Parameters: The method accepts only one parameter mc of MathContext class object which specifies the precision settings for rounding off the BigDecimal. Return Value: This method returns the negated value of the object which is rounded as per the precision settings. Exception: The method might throw ArithmeticException if the result obtained is not exact but the rounding mode is UNNECESSARY. Below programs will illustrate the use of java.math.BigDecimal.negate(MathContext mc) method: Program 1
Negated value, rounded to 4 precision -78.67
Negated value, rounded to 12 precision 178901456.684