mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 12:30:49 +01:00
Compare commits
2 commits
7b0b549e2a
...
f7b866f0bd
Author | SHA1 | Date | |
---|---|---|---|
|
f7b866f0bd | ||
|
04b54abf9e |
1 changed files with 3 additions and 3 deletions
|
@ -948,7 +948,7 @@ func (d Decimal) IsInteger() bool {
|
||||||
q := new(big.Int).Set(d.value)
|
q := new(big.Int).Set(d.value)
|
||||||
for z := abs(d.exp); z > 0; z-- {
|
for z := abs(d.exp); z > 0; z-- {
|
||||||
q.QuoRem(q, tenInt, &r)
|
q.QuoRem(q, tenInt, &r)
|
||||||
if r.Cmp(zeroInt) != 0 {
|
if r.Sign() != 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1210,7 +1210,7 @@ func (d Decimal) Round(places int32) Decimal {
|
||||||
// floor for positive numbers, ceil for negative numbers
|
// floor for positive numbers, ceil for negative numbers
|
||||||
_, m := ret.value.DivMod(ret.value, tenInt, new(big.Int))
|
_, m := ret.value.DivMod(ret.value, tenInt, new(big.Int))
|
||||||
ret.exp++
|
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)
|
ret.value.Add(ret.value, oneInt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,7 +1412,7 @@ func (d Decimal) Ceil() Decimal {
|
||||||
exp.Exp(exp, big.NewInt(-int64(d.exp)), nil)
|
exp.Exp(exp, big.NewInt(-int64(d.exp)), nil)
|
||||||
|
|
||||||
z, m := new(big.Int).DivMod(d.value, exp, new(big.Int))
|
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)
|
z.Add(z, oneInt)
|
||||||
}
|
}
|
||||||
return Decimal{value: z, exp: 0}
|
return Decimal{value: z, exp: 0}
|
||||||
|
|
Loading…
Reference in a new issue