diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index b776cb1dc..cae0a5896 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -178,7 +178,12 @@ object NumberUtil { } fun String.formatNumber(): Long { + var hasDecimal = false var text = replace(",", "") + if (text.contains(".")) { + text = replace(".", "") + hasDecimal = true + } val multiplier = if (text.endsWith("k")) { text = text.substring(0, text.length - 1) 1_000 @@ -186,7 +191,8 @@ object NumberUtil { text = text.substring(0, text.length - 1) 1_000_000 } else 1 - val d = text.toDouble() + var d = text.toDouble() + if (hasDecimal) d /= 10 return (d * multiplier).toLong() } }
\ No newline at end of file |