From 07064c0b8dcce1a9ca48077f9f7b87c21e1466be Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 12 May 2023 23:39:34 +1000 Subject: Visitor drop counter (#103) --- src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt') 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 -- cgit