/**
 * This function rounds a given number to the specified number of decimal places.
 *
 * @param number The number to be rounded.
 * @param decimalPlaces The number of decimal places to round to.
 * @return The rounded number.
 * @throws IllegalArgumentException If decimalPlaces is not a positive integer.
 */
fun roundToNDecimalPlaces(number: Double, decimalPlaces: Int): Double {

    if (decimalPlaces <= 0) {
        throw IllegalArgumentException("decimalPlaces must be a positive integer.")
    }

    val factor = Math.pow(10.0, decimalPlaces.toDouble()).toInt()
    val roundedNumber = Math.round(number * factor) / factor.toDouble()
    return roundedNumber
}
/**
 * This function rounds a given number to the specified number of decimal places.
 *
 * @param number The number to be rounded.
 * @param decimalPlaces The number of decimal places to round to.
 * @return The rounded number.
 * @throws IllegalArgumentException If decimalPlaces is not a positive integer.
 */
fun roundToNDecimalPlaces(number: Double, decimalPlaces: Int): Double {
/**
 * This function rounds a given number to the specified number of decimal places.
 *
 * @param number The number to be rounded.
 * @param decimalPlaces The number of decimal places to round to.
 * @return The rounded number.
 * @throws IllegalArgumentException If decimalPlaces is not a positive integer.
 */
fun roundToNDecimalPlaces(number: Double, decimalPlaces: Int): Double {

    if (decimalPlaces <= 0) {
        throw IllegalArgumentException("decimalPlaces must be a positive integer.")
    }

    val factor = Math.pow(10.0, decimalPlaces.toDouble()).toInt()
    val roundedNumber = Math.round(number * factor) / factor.toDouble()
    return roundedNumber
}