Java BigDecimal Subtract subtract(BigDecimal num1, BigDecimal num2)

Here you can find the source of subtract(BigDecimal num1, BigDecimal num2)

Description

subtract

License

Apache License

Declaration

public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {
    public static final int STANDARD_ROUND_HALF = BigDecimal.ROUND_HALF_UP;
    public static final int STANDARD_SCALE = 2;
    /**/*from  www. ja va  2  s  .  co m*/
     * 0
     **/
    public static final BigDecimal ZERO = new BigDecimal("0");

    public static BigDecimal subtract(BigDecimal num1, BigDecimal num2) {
        if (null == num1 || null == num2) {
            return ZERO;
        }
        BigDecimal temp = num1.subtract(num2);
        return temp.setScale(STANDARD_SCALE, STANDARD_ROUND_HALF);
    }
}

Related

  1. subtract(BigDecimal amount, BigDecimal subtrahend, int scale)
  2. subtract(BigDecimal aValue1, BigDecimal aValue2)
  3. subtract(BigDecimal bigDecimal, BigDecimal bigDecimal2)
  4. subtract(BigDecimal left, BigDecimal right)
  5. subtract(BigDecimal minuend, BigDecimal subtrahend)
  6. subtract(BigDecimal number1, BigDecimal number2, int decimalPlaces)
  7. subtract(BigDecimal one, BigDecimal another)
  8. subtract(BigDecimal v1, BigDecimal v2)
  9. subtract(final BigDecimal baseAmount, final BigDecimal amountToSubtract)