-
Notifications
You must be signed in to change notification settings - Fork 602
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
Convert sdk.Int to BigDec #6409
Changes from all commits
ad759f8
3cc21a8
cb6f73d
938436d
341f982
ef9785c
1f21fc3
4225d5f
39f676a
a16034f
503af84
a574e39
03a878d
88e48d5
9e18a01
507daf3
79f03e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -582,6 +582,12 @@ func BigDecFromDec(d Dec) BigDec { | |
return NewBigDecFromBigIntWithPrec(d.BigInt(), PrecisionDec) | ||
} | ||
|
||
// BigDecFromSDKInt returns the BigDec representation of an sdkInt. | ||
// Values in any additional decimal places are truncated. | ||
func BigDecFromSDKInt(i Int) BigDec { | ||
return NewBigDecFromBigIntWithPrec(i.BigInt(), 0) | ||
} | ||
Comment on lines
+587
to
+589
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this is not mutative. See that Let's still keep this, please. However, I'm also wondering if we can make a mutative version that would reuse the input's buffer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I see, currently it's hard to access There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you make an issue to consider this in the future and potentially talk to the SDK team about exposing such API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created an issue for tracking #17772 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried returning Int.i in my local, performance is improved but the potential risks are unclear |
||
|
||
// BigDecFromDecSlice returns the []BigDec representation of an []Dec. | ||
// Values in any additional decimal places are truncated. | ||
func BigDecFromDecSlice(ds []Dec) []BigDec { | ||
|
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.
nit: I think we do not reference sdk anymore, Int is defined in osmomath package