-
Notifications
You must be signed in to change notification settings - Fork 591
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
feat(osmomath): Power with decimal exponent #3731
Conversation
osmomath/decimal.go
Outdated
// PowerMut returns a result of raising the given big dec to | ||
// a positive decimal power. Panics if the power is negative. | ||
// Panics if the base is negative. Mutates the receiver. | ||
// N.B.: support for negative power can be added when needed. | ||
func (d BigDec) PowerMut(power BigDec) BigDec { | ||
d.i.Set(d.Power(power).i) | ||
return d | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if there is value in this
osmomath/decimal.go
Outdated
func (d BigDec) PowerMut(power BigDec) BigDec { | ||
d.i.Set(d.Power(power).i) | ||
return d | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err this is backwards. We should write the mutative method here, and then have Power just make a copy then run PowerMut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just delete power mut for now
Unless the idea is to keep this as an API stub, to optimize later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to delete this for now.
Since we rely on Exp2
function for the underlying implementation, making a mutative PowerMut
is not as trivial as making MulMut
.
Addressed comments by removing |
Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Can later support negative powers if need arises
Closes: #XXX
What is the purpose of the change
Implements
Power
andPowerMut
with a decimal exponent. Tests added.Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no