Merge pull request #167 from TouchInstinct/amount-with-decimal-decorator-round

amount with decimal decorator round
This commit is contained in:
RationalEgoism 2020-09-14 12:43:59 +03:00 committed by GitHub
commit 468b1ef820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 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,7 @@ class AmountWithDecimalDecorator(
return formatter.format(this.replaceSeparatorsToDot().toDouble().floor())
}
private fun Double.floor() =
(this * 10.toDouble().pow(decimalPartLength)).toLong() / 10.toDouble()
.pow(decimalPartLength)
// TODO make it simple
private fun Double.floor() = (this * 10f.pow(decimalPartLength)).roundToLong() / 10f.pow(decimalPartLength)
}