From 93ea90101984e199d58e484b99d87644eb49b2bc Mon Sep 17 00:00:00 2001 From: Stanisalv Date: Mon, 14 Sep 2020 12:20:43 +0300 Subject: [PATCH] amount with decimal decorator round amount with decimal decorator round --- .../roboswag/views/widget/AmountWithDecimalDecorator.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt b/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt index 0e3794f..281b9c6 100644 --- a/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt +++ b/views/src/main/java/ru/touchin/roboswag/views/widget/AmountWithDecimalDecorator.kt @@ -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) }