Skip to content

Commit

Permalink
Removed unnecessary min function for RescalePair method (#265)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Belsole <chris.belsole@homelight.com>
  • Loading branch information
cbelsole and Chris Belsole committed Jan 15, 2024
1 parent b844c58 commit b79c571
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions decimal.go
Expand Up @@ -1672,22 +1672,13 @@ func RescalePair(d1 Decimal, d2 Decimal) (Decimal, Decimal) {
d1.ensureInitialized()
d2.ensureInitialized()

if d1.exp == d2.exp {
return d1, d2
if d1.exp < d2.exp {
return d1, d2.rescale(d1.exp)
} else if d1.exp > d2.exp {
return d1.rescale(d2.exp), d2
}

baseScale := min(d1.exp, d2.exp)
if baseScale != d1.exp {
return d1.rescale(baseScale), d2
}
return d1, d2.rescale(baseScale)
}

func min(x, y int32) int32 {
if x >= y {
return y
}
return x
return d1, d2
}

func unquoteIfQuoted(value interface{}) (string, error) {
Expand Down

0 comments on commit b79c571

Please sign in to comment.