package com.cirle.scientific.utils;

import java.text.NumberFormat;

public class CalculateProportionUti {


    /**
     * 计算百分⽐整数
     *
     * @param divisor
     * @param dividend
     * @return
     */
    public static String proportionInt(Integer divisor, Integer dividend) {
        if (dividend == null || divisor == null)
            return null;
        NumberFormat numberFormat = NumberFormat.getInstance();
        // 设置精确到⼩数点后2位
        numberFormat.setMaximumFractionDigits(2);
        String result = numberFormat.format((float) divisor / (float) dividend * 100);
        if (result.indexOf(".") != -1) {
            result = Math.round(Double.parseDouble(result))+"";
        }
        return result;
    }
}
