Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-22 18:51:03 +05:00
parent 77103de5d7
commit b2196196e7

View file

@ -161,7 +161,7 @@ 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 when {
this.endsWith('0') -> this
this.endsWith('0') && parsedDecimal?.scale() != 0 -> this
parsedDecimal?.scale() == 0 && trailingZeros.isNotEmpty() -> "$this$decimalSymbol$trailingZeros"
else -> this.plus(trailingZeros)
}