package com.xty.common.util

import java.math.BigDecimal

object NumUtils {

    fun divide(valueOne: Int, valueTwo: Int, scale: Int): Double {
        if (scale < 0) {
            throw IllegalArgumentException("The scale must be a positive integer or zero")
        }
        val b1 = BigDecimal(java.lang.Double.toString(valueOne.toDouble()))
        val b2 = BigDecimal(java.lang.Double.toString(valueTwo.toDouble()))
        return b1.divide(b2, scale, BigDecimal.ROUND_HALF_UP).toDouble()
    }
}