package com.dashitech.utils;

import java.math.BigDecimal;



/**
 * 价格计算工具类
 */
public class DecimalUtil {
	private static final int DIV_SCALE = 50;
 
	/**
	 * 相加
	 */
	public static BigDecimal sum(Object first,Object second) {
		BigDecimal _first = new BigDecimal(first.toString());
		BigDecimal _second = new BigDecimal(second.toString());
		return _first.add(_second);
	}
	
	/**
	 * 相减
	 */
	public static BigDecimal sub(Object first,Object second) {
		BigDecimal _first = new BigDecimal(first.toString());
		BigDecimal _second = new BigDecimal(second.toString());
		return _first.subtract(_second);
	}
	
	/**
	 * 相乘
	 */
	public static BigDecimal ride(Object first,Object second) {
		BigDecimal _first = new BigDecimal(first.toString());
		BigDecimal _second = new BigDecimal(second.toString());
		return _first.multiply(_second);
    }
	
	/**
	 * 相除
	 */
	public static BigDecimal div(Object first,Object second) {
		BigDecimal _first = new BigDecimal(first.toString());
		BigDecimal _second = new BigDecimal(second.toString());
		 return _first.divide(_second,DIV_SCALE,BigDecimal.ROUND_HALF_DOWN);
	}

}
