From b844c58a7167f7d2e04e11d6a999c79d8bbfaec7 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 16 Jan 2024 03:52:54 +0800 Subject: [PATCH] Fix overflow edge case in QuoRem method (#322) --- decimal.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decimal.go b/decimal.go index f240dc5..e9d1627 100644 --- a/decimal.go +++ b/decimal.go @@ -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") }