Here you can find the source of subtract(BigDecimal amount, BigDecimal subtrahend, int scale)
public static BigDecimal subtract(BigDecimal amount, BigDecimal subtrahend, int scale)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static BigDecimal subtract(BigDecimal amount, BigDecimal subtrahend, int scale) { return roundBigDecimal(amount.subtract(subtrahend), scale); }//from w ww . j a va 2s. co m public static BigDecimal subtract(BigDecimal... amounts) { return subtract(2, amounts); } public static BigDecimal subtract(int scale, BigDecimal... amounts) { BigDecimal result = null; for (BigDecimal bigDecimal : amounts) { if (bigDecimal != null) { result = result == null ? bigDecimal : result.subtract(bigDecimal); } } return roundBigDecimal(result); } public static BigDecimal roundBigDecimal(BigDecimal num) { return roundBigDecimal(num, 2); } public static BigDecimal roundBigDecimal(BigDecimal num, int scale) { if (num != null) { return num.setScale(scale, RoundingMode.HALF_UP); } return num; } }