package com.example.base.extensions

import java.math.RoundingMode
import java.text.DecimalFormat

fun Double.toTwoDecimal(): String {
    val df = DecimalFormat()
    df.applyPattern("#0.00")
    df.roundingMode = RoundingMode.FLOOR
    return df.format(this)
}

fun Double.toTwoDecimalUP(): String {
    val df = DecimalFormat()
    df.applyPattern("#0.00")
    df.roundingMode = RoundingMode.HALF_UP
    return df.format(this)
}

fun Float.toTwoDecimal(): String {
    val df = DecimalFormat()
    df.applyPattern("#0.00")
    df.roundingMode = RoundingMode.FLOOR
    return df.format(this)
}

fun Float.toTwoDecimalUP(): String {
    val df = DecimalFormat()
    df.applyPattern("#0.00")
    df.roundingMode = RoundingMode.HALF_UP
    return df.format(this)
}