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

uint: implement integer_sqrt #554

Merged
merged 8 commits into from Jun 30, 2021
Merged

uint: implement integer_sqrt #554

merged 8 commits into from Jun 30, 2021

Conversation

ordian
Copy link
Member

@ordian ordian commented Jun 28, 2021

Closes #551.

The algorithm implemented is the same as in the integer-sqrt crate and it's quite slow, on my machine u256 isqrt takes 2μs (>2000ns) and u512 > 5μs.

Do you know of any better algorithms?

@ordian
Copy link
Member Author

ordian commented Jun 28, 2021

@xlc are you OK with integer-sqrt support, or do you actually need num_traits::int::PrimInt impl?

@xlc
Copy link
Contributor

xlc commented Jun 28, 2021

integer-sqrt will do it for now.

uint/fuzz/fuzz_targets/div_mod.rs Show resolved Hide resolved
@@ -9,4 +9,5 @@ edition = "2018"

[dependencies]
num-traits = { version = "0.2", default-features = false }
integer-sqrt = "0.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is independent of the num-traits feature?

Copy link
Member Author

@ordian ordian Jun 29, 2021

Choose a reason for hiding this comment

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

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

LGTM but I also have not looked deeply into the algos used here.

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.

implement num_traits::int::PrimInt for U256 / U512
4 participants