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

Add abs_diff function for math package #1334

Merged
merged 4 commits into from
Jun 13, 2022

Conversation

y-pakorn
Copy link
Contributor

@y-pakorn y-pakorn commented Jun 12, 2022

This should be a part of #1186

Add the abs_diff function for calculating the absolute difference in cosmwasm-math package as suggested

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Nice, thank you. Can you make them const? Also I'd use other: Self consistently which seems a bit cleaner than the various sort of Into types.

@y-pakorn
Copy link
Contributor Author

const abs_diff relies on primitive abs_diff which make the function not applicable to const identifier on Uint256 and Uint512 because the uint package has no native constant function to evaluate order and operation without panics.

We might just not use const abs_diff altogether (just normal abs_diff) and make all the functions able to run on Rust version lower than 1.60.0 too.

@webmaster128
Copy link
Member

I see. Our < and - implementations are not const. Only the standard library can do const trait implementations.

@webmaster128
Copy link
Member

Okay, let's make the Uint64/Uint128/Decimal case const. For the others we find a different implementation to constify them later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants