package com.zt.plat.module.qms.core.qlexpress.function;

import java.math.BigDecimal;
import java.math.RoundingMode;

import com.ql.util.express.Operator;

public class RoundToScaleHalfEven extends Operator {

	@Override
	public Object executeInner(Object[] list) throws Exception {
		if (list.length != 2) {
            throw new Exception("roundToScale函数需要2个参数：数值和小数位数");
        }
        
        double value = Double.parseDouble(list[0].toString());
        int scale = Integer.parseInt(list[1].toString());
        
        BigDecimal bd = BigDecimal.valueOf(value);
        bd = bd.setScale(scale, RoundingMode.HALF_EVEN);
        return bd;
	}


}
