Merge pull request #144 from forsaken628/patch-1

fix: Coefficient panic
This commit is contained in:
Jason Biegel 2019-10-08 22:49:08 -04:00 committed by GitHub
commit 2677b5dba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -657,6 +657,7 @@ func (d Decimal) Exponent() int32 {
// Coefficient returns the coefficient of the decimal. It is scaled by 10^Exponent()
func (d Decimal) Coefficient() *big.Int {
d.ensureInitialized()
// we copy the coefficient so that mutating the result does not mutate the
// Decimal.
return big.NewInt(0).Set(d.value)