Here you can find the source of round(BigDecimal v, int scale, int roundingMode)
public static BigDecimal round(BigDecimal v, int scale, int roundingMode)
//package com.java2s; import java.math.BigDecimal; public class Main { public static int round(double v) { return round(new BigDecimal(v), 0, BigDecimal.ROUND_HALF_UP).intValue(); }//www . j a v a 2 s . c o m public static BigDecimal round(BigDecimal v, int scale, int roundingMode) { if (scale < 0 || roundingMode < 0) { throw new IllegalArgumentException("The scale or roundingMode must be a positive integer or zero"); } return v.divide(BigDecimal.ONE, scale, roundingMode); } public static BigDecimal divide(String v1, String v2) { return divide(new BigDecimal(v1), new BigDecimal(v2)); } public static BigDecimal divide(double v1, double v2) { return divide(new BigDecimal(v1), new BigDecimal(v2)); } public static BigDecimal divide(BigDecimal v1, BigDecimal v2) { return divide(v1, v2, 2, BigDecimal.ROUND_HALF_UP); } public static BigDecimal divide(BigDecimal v1, BigDecimal v2, int scale, int roundingMode) { return v1.divide(v2, scale, roundingMode); } }