Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static double divAddGoods(String value1, String value2) { if ("0.".equals(value2)) { value2 = "1"; } double v1 = Double.parseDouble(value1); double v2 = Double.parseDouble(value2); BigDecimal b1 = new BigDecimal(v1); BigDecimal b2 = new BigDecimal((v2)); return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue(); } }