Here you can find the source of div(Object a, Object b)
public static Object div(Object a, Object b)
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static Object div(Object a, Object b) { if (a == null || b == null) { return null; }//w ww .j a va 2s . co m BigDecimal decimalA = decimal(a); BigDecimal decimalB = decimal(b); try { return decimalA.divide(decimalB); } catch (ArithmeticException ex) { return decimalA.divide(decimalB, 4, RoundingMode.CEILING); } } public static BigDecimal decimal(Object val) { if (val == null) { return null; } if (val instanceof BigDecimal) { return (BigDecimal) val; } if (val instanceof String) { return new BigDecimal((String) val); } if (val instanceof Float) { return new BigDecimal((Float) val); } if (val instanceof Double) { return new BigDecimal((Double) val); } return BigDecimal.valueOf(((Number) val).longValue()); } }