aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index cae0a5896..57c7b3b84 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -178,12 +178,8 @@ 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
@@ -191,8 +187,7 @@ object NumberUtil {
text = text.substring(0, text.length - 1)
1_000_000
} else 1
- var d = text.toDouble()
- if (hasDecimal) d /= 10
+ val d = text.toDouble()
return (d * multiplier).toLong()
}
} \ No newline at end of file