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

pow impl for u256 #5195

Merged
merged 24 commits into from
Oct 24, 2023
Merged

pow impl for u256 #5195

merged 24 commits into from
Oct 24, 2023

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Oct 13, 2023

Description

This PR is part of #4794 and it implements pow for u256. It is using the same algorithm as Rust stdlib https://github.com/rust-lang/rust/blob/193e8a196b7700542473a477effd8c6c5786f8de/library/core/src/num/uint_macros.rs#L1976.

#4900 implements pow for U256 (upper case U) which is being deprecated.

Closes #4449

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@eureka-cpu
Copy link
Contributor

This is a duplicate of #4900

@xunilrj
Copy link
Contributor Author

xunilrj commented Oct 16, 2023

This is a duplicate of #4900

#4900 is actually implementing pow for U256 which is being deprecated. I added this details on the description.

@xunilrj xunilrj requested a review from a team October 16, 2023 11:41
sway-lib-core/src/ops.sw Outdated Show resolved Hide resolved
sway-lib-std/src/math.sw Outdated Show resolved Hide resolved
@xunilrj xunilrj self-assigned this Oct 16, 2023
@IGI-111 IGI-111 requested a review from a team October 16, 2023 13:29
IGI-111
IGI-111 previously approved these changes Oct 16, 2023
@IGI-111 IGI-111 requested a review from a team October 16, 2023 13:30
@xunilrj xunilrj mentioned this pull request Oct 16, 2023
7 tasks
@xunilrj xunilrj requested a review from IGI-111 October 16, 2023 16:09
IGI-111
IGI-111 previously approved these changes Oct 16, 2023
@IGI-111 IGI-111 requested a review from a team October 16, 2023 16:55
@xunilrj xunilrj requested a review from IGI-111 October 19, 2023 10:58
@xunilrj
Copy link
Contributor Author

xunilrj commented Oct 19, 2023

@IGI-111 mind reviewing again? I have rebased to the new pow with u32..

IGI-111
IGI-111 previously approved these changes Oct 19, 2023
@xunilrj xunilrj requested a review from a team October 19, 2023 14:19
ironcev
ironcev previously approved these changes Oct 22, 2023
Copy link
Member

@ironcev ironcev left a comment

Choose a reason for hiding this comment

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

Algorithm looks fine, added functions, everything. I would still rename the exp/expon parameters to exponent for the sake of consistency with other Power impls.

sway-lib-std/src/u256.sw Outdated Show resolved Hide resolved
sway-lib-std/src/math.sw Outdated Show resolved Hide resolved
@xunilrj xunilrj dismissed stale reviews from IGI-111 and ironcev via 0042f71 October 22, 2023 23:57
ironcev
ironcev previously approved these changes Oct 23, 2023
@IGI-111
Copy link
Contributor

IGI-111 commented Oct 23, 2023

Looks like splitting the stdlib for the lsp tests broke the fix. This should pass with it removed.

@IGI-111 IGI-111 enabled auto-merge (squash) October 24, 2023 08:33
@IGI-111 IGI-111 merged commit 1762793 into master Oct 24, 2023
29 checks passed
@IGI-111 IGI-111 deleted the xunilrj/u256-pow branch October 24, 2023 09:17
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.

Power impl for U256 in std lib
5 participants