Format file.

This commit is contained in:
FireMasterK 2022-02-14 20:57:50 +00:00
parent 24e31c4efb
commit 87c52f7e58
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -4,19 +4,19 @@ import java.math.BigDecimal
import java.math.RoundingMode
fun Long?.formatShort(): String = when {
this!!<1000 -> {
this.toString()
}
this in 1000..999999 -> {
val decimal = BigDecimal(this/1000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString()+"K"
}
this in 1000000..10000000 -> {
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString()+"M"
}
else -> {
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString()+"M"
}
}
this!! < 1000 -> {
this.toString()
}
this in 1000..999999 -> {
val decimal = BigDecimal(this / 1000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString() + "K"
}
this in 1000000..10000000 -> {
val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString() + "M"
}
else -> {
val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN)
decimal.toString() + "M"
}
}