Here you can find the source of divideNumber(Object divisor, Object dividend)
public static String divideNumber(Object divisor, Object dividend)
//package com.java2s; //License from project: Apache License import java.math.BigDecimal; public class Main { public static String divideNumber(Object divisor, Object dividend) { if (divisor == null || dividend == null) { return ""; }//ww w .j a v a 2 s. c o m BigDecimal a = toBig(divisor); BigDecimal b = toBig(dividend); if (a.equals(toBig(0)) || b.equals(toBig(0))) { return "0"; } BigDecimal c = a.divide(b, 2, BigDecimal.ROUND_DOWN); return c.toString(); } public static BigDecimal toBig(Object o) { if (o == null || o.toString().equals("") || o.toString().equals("NaN")) { return new BigDecimal(0); } return new BigDecimal(o.toString()); } }