Updated on 2026-08-14

This commit is contained in:
Tangem 2022-08-16 10:51:47 +03:00
commit b94f0e2f04

View file

@ -116,6 +116,8 @@ fun BigDecimal.formatAmountAsSpannedString(
val integer = amount.substringBefore('.')
val reminder = amount.substringAfter('.')
// test formatter log Log.e("TEST ", BigDecimal("1234567890987654321.1234567890987654321").formatWithSpaces())
return buildSpannedString {
append(integer)
append('.')
@ -136,7 +138,7 @@ fun BigDecimal.formatWithSpaces(): String {
var index: Int = integerStr.length
while (0 < index) {
if (index <= 3) {
packets.add(0, integerStr)
packets.add(integerStr)
break
}
index -= 3
@ -145,7 +147,7 @@ fun BigDecimal.formatWithSpaces(): String {
}
return buildString {
packets.forEachIndexed { index, packet ->
packets.reversed().forEachIndexed { index, packet ->
append(packet)
if (index != packets.lastIndex) append(' ')
}