diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt index f6efc24fd..8edc18204 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/math/Decimal.kt @@ -605,8 +605,16 @@ class Decimal @JvmOverloads constructor(whole: BigInteger, decimal: Double = 0.0 return BigDecimal(whole) + BigDecimal(decimal) } + private var _signum = Int.MIN_VALUE + fun signum(): Int { - return whole.signum() + if (_signum == Int.MIN_VALUE) { + var cmp = whole.signum() + if (cmp == 0) cmp = if (decimal == 0.0) 0 else if (1.0 / decimal > 0.0) 1 else -1 + _signum = cmp + } + + return _signum } override fun compareTo(other: Decimal): Int {