diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-02 21:20:15 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-04-02 21:20:15 +0200 |
commit | 479da66e2d7fcfb5c0bc432f26a01185f36ef8ba (patch) | |
tree | d9c1e382baa653070b91aa8b9934750d9fe547ba /src/main/java | |
parent | d4db73b314e7a31f4e8c0954d747b2ac8214139e (diff) | |
download | skyhanni-479da66e2d7fcfb5c0bc432f26a01185f36ef8ba.tar.gz skyhanni-479da66e2d7fcfb5c0bc432f26a01185f36ef8ba.tar.bz2 skyhanni-479da66e2d7fcfb5c0bc432f26a01185f36ef8ba.zip |
More exact number format for numbers greater than 10m
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 397613f40..a3c86c0f4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -1,6 +1,5 @@ package at.hannibal2.skyhanni.utils -import at.hannibal2.skyhanni.utils.NumberUtil.addSuffix import java.text.NumberFormat import java.util.* import java.util.regex.Pattern @@ -51,7 +50,8 @@ object NumberUtil { if (value < 1000) return value.toString() //deal with easy case val (divideBy, suffix) = suffixes.floorEntry(value) val truncated = value / (divideBy / 10) //the number part of the output times 10 - val hasDecimal = truncated < 100 && truncated / 10.0 != (truncated / 10).toDouble() + val truncatedAt = if (suffix == "M") 1000 else 100 + val hasDecimal = truncated < truncatedAt && truncated / 10.0 != (truncated / 10).toDouble() return if (hasDecimal) (truncated / 10.0).toString() + suffix else (truncated / 10).toString() + suffix } |