We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Add Abs() method to sdk.Int, just like sdk.Dec.
Abs()
sdk.Int
sdk.Dec
Getting an absolute value from an integer type is very basic feature, but is missing. Without this simple Abs() method, one should write:
abs := val if abs.IsNegative() { abs = abs.Neg() }
Just add Abs() method to sdk.Int like this(following conventions in types/int.go):
func abs(i *big.Int) *big.Int { return new(big.Int).Abs(i) } ... // Abs returns the absolute value of Int. func (i Int) Abs() Int { return Int{abs(i.i)} }
The text was updated successfully, but these errors were encountered:
I'll work on this feature and submit PR.
Sorry, something went wrong.
types: add Abs() method to sdk.Int (#8963)
8ee9da7
Fixes #8962 Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Successfully merging a pull request may close this issue.
Summary
Add
Abs()
method tosdk.Int
, just likesdk.Dec
.Problem Definition
Getting an absolute value from an integer type is very basic feature, but is missing.
Without this simple
Abs()
method, one should write:Proposal
Just add
Abs()
method tosdk.Int
like this(following conventions in types/int.go):For Admin Use
The text was updated successfully, but these errors were encountered: