Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osmomath: AddMut and QuoMut #3779

Merged
merged 13 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 548207900.mdttt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- mut add
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this

- test add mut
- quo mut
- test quo mut/ remove want from test struct

<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for creating a PR! ✰
v Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
v If your PR doesn't close an issue, that's OK! Just remove the Closes: #XXX line!
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

Closes: #3773

## What is the purpose of the change
mutative add and quo + tests
8 changes: 4 additions & 4 deletions osmomath/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ func (d BigDec) Quo(d2 BigDec) BigDec {
// mutative quotient
func (d BigDec) QuoMut(d2 BigDec) BigDec {
pysel marked this conversation as resolved.
Show resolved Hide resolved
// multiply precision twice
mul := new(big.Int).Mul(d.i, precisionReuse)
mul.Mul(mul, precisionReuse)
d.i.Mul(d.i, precisionReuse)
d.i.Mul(d.i, precisionReuse)

d.i.Quo(mul, d2.i)
d.i = chopPrecisionAndRound(d.i)
d.i.Quo(d.i, d2.i)
chopPrecisionAndRound(d.i)

if d.i.BitLen() > maxDecBitLen {
panic("Int overflow")
Expand Down
1 change: 0 additions & 1 deletion osmomath/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func TestQuoMut(t *testing.T) {
for _, tc := range tests {
if !tc.expectingErr {
want := tc.testing.Quo(tc.quo)
fmt.Println(tc.testing, tc.quo)
tc.testing.QuoMut(tc.quo)

require.Equal(t, want, tc.testing)
Expand Down