Methods used to do calculation

ReturnMethod
BigDecimalabs()
BigDecimalabs(MathContext mc)
BigDecimaladd(BigDecimal augend)
BigDecimaladd(BigDecimal augend, MathContext mc)
BigDecimaldivide(BigDecimal divisor)
BigDecimaldivide(BigDecimal divisor, int roundingMode)
BigDecimaldivide(BigDecimal divisor, int scale, int roundingMode)
BigDecimaldivide(BigDecimal divisor, int scale, RoundingMode roundingMode)
BigDecimaldivide(BigDecimal divisor, MathContext mc)
BigDecimaldivide(BigDecimal divisor, RoundingMode roundingMode)
BigDecimal[]divideAndRemainder(BigDecimal divisor)
BigDecimal[]divideAndRemainder(BigDecimal divisor, MathContext mc)
BigDecimaldivideToIntegralValue(BigDecimal divisor)
BigDecimaldivideToIntegralValue(BigDecimal divisor, MathContext mc)
BigDecimalmax(BigDecimal val)
BigDecimalmin(BigDecimal val)
BigDecimalmultiply(BigDecimal multiplicand)
BigDecimalmultiply(BigDecimal multiplicand, MathContext mc)
BigDecimalnegate()
BigDecimalnegate(MathContext mc)
BigDecimalplus()
BigDecimalplus(MathContext mc)
BigDecimalpow(int n)
BigDecimalpow(int n, MathContext mc)
BigDecimalremainder(BigDecimal divisor)
BigDecimalremainder(BigDecimal divisor, MathContext mc)
BigDecimalround(MathContext mc)
BigDecimalscaleByPowerOfTen(int n)
BigDecimalsubtract(BigDecimal subtrahend)
BigDecimalsubtract(BigDecimal subtrahend, MathContext mc)

import java.math.BigDecimal;
 

public class Main {
 
    public static void main(String[] args) {
        BigDecimal first = new BigDecimal(-1f);
        System.out.println(first);
        System.out.println(first.abs());
    }
}

The output:


-1
1

import java.math.BigDecimal;
 

public class Main {
 
    public static void main(String[] args) {
        BigDecimal first = new BigDecimal(-1f);
        BigDecimal second = new BigDecimal(10f);
 
        BigDecimal result = first.add(second); 
        System.out.println(result);
    }
}

The output:


9
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.