Skip to content

Commit

Permalink
Fix overflow edge case in QuoRem method (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankli0324 authored Jan 15, 2024
1 parent 142a0cf commit b844c58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ func (d Decimal) QuoRem(d2 Decimal, precision int32) (Decimal, Decimal) {
panic("decimal division by 0")
}
scale := -precision
e := int64(d.exp - d2.exp - scale)
e := int64(d.exp) - int64(d2.exp) - int64(scale)
if e > math.MaxInt32 || e < math.MinInt32 {
panic("overflow in decimal QuoRem")
}
Expand Down

0 comments on commit b844c58

Please sign in to comment.