Skip to content

Commit

Permalink
bugfix: decimal use a test variable
Browse files Browse the repository at this point in the history
The patch replaces usage of a test variable DecimalPrecision by
a package-level variable decimalPrecision in the decimal package
code.
  • Loading branch information
oleg-jukovec committed Nov 18, 2022
1 parent 48cf0c7 commit d34ef40
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions decimal/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func NewDecimalFromString(src string) (result *Decimal, err error) {
// MarshalMsgpack serializes the Decimal into a MessagePack representation.
func (decNum *Decimal) MarshalMsgpack() ([]byte, error) {
one := decimal.NewFromInt(1)
maxSupportedDecimal := decimal.New(1, DecimalPrecision).Sub(one) // 10^DecimalPrecision - 1
maxSupportedDecimal := decimal.New(1, decimalPrecision).Sub(one) // 10^DecimalPrecision - 1
minSupportedDecimal := maxSupportedDecimal.Neg().Sub(one) // -10^DecimalPrecision - 1
if decNum.GreaterThan(maxSupportedDecimal) {
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", DecimalPrecision)
return nil, fmt.Errorf("msgpack: decimal number is bigger than maximum supported number (10^%d - 1)", decimalPrecision)
}
if decNum.LessThan(minSupportedDecimal) {
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", DecimalPrecision)
return nil, fmt.Errorf("msgpack: decimal number is lesser than minimum supported number (-10^%d - 1)", decimalPrecision)
}

strBuf := decNum.String()
Expand Down

0 comments on commit d34ef40

Please sign in to comment.