amount with decimal decorator round

amount with decimal decorator round
This commit is contained in:
Stanisalv 2020-09-14 12:20:43 +03:00
parent e5d6a02617
commit 93ea901019
1 changed files with 2 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.pow
import kotlin.math.roundToLong
class AmountWithDecimalDecorator(
val editText: EditText,
@ -214,8 +215,6 @@ class AmountWithDecimalDecorator(
return formatter.format(this.replaceSeparatorsToDot().toDouble().floor())
}
private fun Double.floor() =
(this * 10.toDouble().pow(decimalPartLength)).toLong() / 10.toDouble()
.pow(decimalPartLength)
private fun Double.floor() = (this * 10f.pow(decimalPartLength)).roundToLong() / 10f.pow(decimalPartLength)
}