aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt6
3 files changed, 6 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt
index 7b6fa9bc5..6e755d874 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/experimentationtable/ExperimentsProfitTracker.kt
@@ -25,10 +25,10 @@ import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalNameOrNull
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.round
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.roundTo
import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
import at.hannibal2.skyhanni.utils.RegexUtils.matches
@@ -162,7 +162,7 @@ object ExperimentsProfitTracker {
val price = internalName.getPrice()
val npcPrice = internalName.getNpcPriceOrNull() ?: 0.0
val maxPrice = npcPrice.coerceAtLeast(price)
- startCostTemp += maxPrice.round(0).toInt()
+ startCostTemp += maxPrice.roundTo(0).toInt()
iterator.remove()
}
tracker.modify {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index cd96121c4..e4e74b0d2 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -101,10 +101,10 @@ object LorenzUtils {
return originalMessage.stripHypixelMessage()
}
- @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(decimals)"))
fun Double.round(decimals: Int) = this.roundTo(decimals)
- @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
+ @Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(decimals)"))
fun Float.round(decimals: Int) = this.roundTo(decimals)
// TODO replace all calls with regex
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
index 58441ecab..dc7c4828c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt
@@ -83,12 +83,10 @@ object NumberUtil {
*/
fun Double.roundTo(precision: Int): Double {
val scale = 10.0.pow(precision)
- return kotlin.math.round(scale) / scale
+ return kotlin.math.round(this * scale) / scale
}
- fun Float.roundTo(precision: Int): Float {
- return toDouble().roundTo(precision).toFloat()
- }
+ fun Float.roundTo(precision: Int): Float = toDouble().roundTo(precision).toFloat()
@Deprecated("Use roundTo instead", ReplaceWith("this.roundTo(precision)"))
fun Double.roundToPrecision(precision: Int) = this.roundTo(precision)