Here you can find the source of div(double divisor, int dividend, int preciseFigures)
public static double div(double divisor, int dividend, int preciseFigures)
//package com.java2s; /**//from ww w . j a v a2 s . co m * ============================================================================== * Copyright (c) 2015 by www.dianxin.com, All rights reserved. * ============================================================================== * This software is the confidential and proprietary information of * tencent.com, Inc. ("Confidential Information"). You shall not disclose * such Confidential Information and shall use it only in accordance * with the terms of the license agreement you entered into with dianxin.com, Inc. * ------------------------------------------------------------------------------ * <p/> * Author: faberxu * Date: 2015/12/18 * Description: ?????? * Nothing. * Function List: * 1. Nothing. * History: * 1. Nothing. * ============================================================================== */ import java.math.BigDecimal; public class Main { public static double div(double divisor, int dividend, int preciseFigures) { if (divisor > 0 && dividend > 0) { BigDecimal ds = new BigDecimal(divisor); BigDecimal dd = new BigDecimal(dividend); double result = ds.divide(dd, preciseFigures, BigDecimal.ROUND_HALF_UP).doubleValue(); return result; } else { return 0; } } }