mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 20:40:48 +01:00
fix: Coefficient panic
call Coefficient on uninitialized Decimal will panic
This commit is contained in:
parent
cd690d0c9e
commit
62587fc365
1 changed files with 1 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue