aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-18 21:50:55 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-18 21:50:55 +0100
commit869d7a10cb1bf3d471655e96217325a767f7d943 (patch)
treebbab08516ae3351b883404944226a5d0a726b811 /src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
parente3a83c160bebdc06b7597b9a19d406468d4b1305 (diff)
downloadskyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.tar.gz
skyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.tar.bz2
skyhanni-869d7a10cb1bf3d471655e96217325a767f7d943.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index bccf92e62..d03455ac9 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -163,12 +163,10 @@ object NumberUtil {
} else romanSymbols[l] + (this - l).toRoman()
}
- private fun processDecimal(decimal: Int, lastNumber: Int, lastDecimal: Int): Int {
- return if (lastNumber > decimal) {
- lastDecimal - decimal
- } else {
- lastDecimal + decimal
- }
+ private fun processDecimal(decimal: Int, lastNumber: Int, lastDecimal: Int) = if (lastNumber > decimal) {
+ lastDecimal - decimal
+ } else {
+ lastDecimal + decimal
}
val pattern = "^[0-9]*$".toPattern()
@@ -193,18 +191,19 @@ object NumberUtil {
val multiplier = if (text.endsWith("k")) {
text = text.substring(0, text.length - 1)
- 1_000
+ 1_000.0
} else if (text.endsWith("m")) {
text = text.substring(0, text.length - 1)
- 1_000_000
- }else if (text.endsWith("b")) {
+ 1.milion
+ } else if (text.endsWith("b")) {
text = text.substring(0, text.length - 1)
- 1_000_000_000
- }else 1
+ 1.bilion
+ } else 1.0
val d = text.toDouble()
return (d * multiplier).toLong()
}
val Int.milion get() = this * 1_000_000.0
+ val Int.bilion get() = this * 1_000_000_000.0
val Double.milion get() = (this * 1_000_000.0).toLong()
}