From a2e3711ce09fce2e148addc78105b2b659f3f2fe Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 23 May 2023 20:05:59 -0400 Subject: [PATCH] fix: legacy dec power mut zero exponent precision (#16266) --- math/CHANGELOG.md | 4 ++++ math/dec.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/math/CHANGELOG.md b/math/CHANGELOG.md index 0c7a63d2bc..b337d786d4 100644 --- a/math/CHANGELOG.md +++ b/math/CHANGELOG.md @@ -36,6 +36,10 @@ Ref: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.j ## [Unreleased] +### Bug Fixes + +* [#16266](https://github.com/cosmos/cosmos-sdk/pull/16266) fix: legacy dec power mut zero exponent precision. + ## [math/v1.0.1](https://github.com/cosmos/cosmos-sdk/releases/tag/math/v1.0.1) - 2023-05-15 ### Improvements diff --git a/math/dec.go b/math/dec.go index 0f6918bd4b..d92b0042f3 100644 --- a/math/dec.go +++ b/math/dec.go @@ -490,7 +490,8 @@ func (d LegacyDec) Power(power uint64) LegacyDec { func (d LegacyDec) PowerMut(power uint64) LegacyDec { if power == 0 { - d.SetInt64(1) + // Set to 1 with the correct precision. + d.i.Set(precisionReuse) return d } tmp := LegacyOneDec()