Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-22 15:46:28 +05:00
parent 27f3c6afda
commit a204ef0bd6
4 changed files with 62 additions and 14 deletions

View file

@ -160,10 +160,10 @@ private fun String.preserveDecimalSymbol(newValue: String, decimalSymbol: Char)
private fun String.preserveTrailingZeros(newValue: String, parsedDecimal: BigDecimal?, decimalSymbol: Char): String {
val trailingZeros = newValue.split(decimalSymbol).getOrNull(1)?.takeLastWhile { it == '0' }.orEmpty()
return if (parsedDecimal?.scale() == 0 && trailingZeros.isNotEmpty()) {
"$this$decimalSymbol$trailingZeros"
} else {
this.plus(trailingZeros)
return when {
this.endsWith('0') -> this
parsedDecimal?.scale() == 0 && trailingZeros.isNotEmpty() -> "$this$decimalSymbol$trailingZeros"
else -> this.plus(trailingZeros)
}
}