Here you can find the source of divide(String num1, String num2, int scale)
public static BigDecimal divide(String num1, String num2, int scale)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static BigDecimal divide(String num1, String num2, int scale) { num1 = checkNum(num1);// ww w .j a v a 2 s. c om if ("".equals(num2)) { num2 = "1"; } BigDecimal bd1 = new BigDecimal(num1); BigDecimal bd2 = new BigDecimal(num2); return bd1.divide(bd2, scale, BigDecimal.ROUND_HALF_UP); } private static String checkNum(String num) { if ("".equals(num)) { num = "0"; } return num; } }