aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-05-12 23:39:34 +1000
committerGitHub <noreply@github.com>2023-05-12 15:39:34 +0200
commit07064c0b8dcce1a9ca48077f9f7b87c21e1466be (patch)
tree6a9ac4b084c3fcec904b52fc219bab4c68b2593c /src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
parent233b5d9b79afce09b830df22b89bc99180b5b991 (diff)
downloadskyhanni-07064c0b8dcce1a9ca48077f9f7b87c21e1466be.tar.gz
skyhanni-07064c0b8dcce1a9ca48077f9f7b87c21e1466be.tar.bz2
skyhanni-07064c0b8dcce1a9ca48077f9f7b87c21e1466be.zip
Visitor drop counter (#103)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt8
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