Fix previous commit losing sign in fractional numbers
This commit is contained in:
parent
de67209d24
commit
5626ca22d8
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user