From 04b54abf9e83c11fd85ade780d3f35453310bf16 Mon Sep 17 00:00:00 2001 From: terry Date: Sat, 5 Nov 2022 14:10:29 +0800 Subject: [PATCH] use to determine whether it equals 0 or not. r.Cmp(zeroInt) != 0 => r.Sign() != 0 --- decimal.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decimal.go b/decimal.go index c614ea7..c0a95f4 100644 --- a/decimal.go +++ b/decimal.go @@ -834,7 +834,7 @@ func (d Decimal) IsInteger() bool { q := new(big.Int).Set(d.value) for z := abs(d.exp); z > 0; z-- { q.QuoRem(q, tenInt, &r) - if r.Cmp(zeroInt) != 0 { + if r.Sign() != 0 { return false } } @@ -1093,7 +1093,7 @@ func (d Decimal) Round(places int32) Decimal { // floor for positive numbers, ceil for negative numbers _, m := ret.value.DivMod(ret.value, tenInt, new(big.Int)) ret.exp++ - if ret.value.Sign() < 0 && m.Cmp(zeroInt) != 0 { + if ret.value.Sign() < 0 && m.Sign() != 0 { ret.value.Add(ret.value, oneInt) } @@ -1298,7 +1298,7 @@ func (d Decimal) Ceil() Decimal { exp.Exp(exp, big.NewInt(-int64(d.exp)), nil) z, m := new(big.Int).DivMod(d.value, exp, new(big.Int)) - if m.Cmp(zeroInt) != 0 { + if m.Sign() != 0 { z.Add(z, oneInt) } return Decimal{value: z, exp: 0}