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
Conversation
@xlc are you OK with |
|
@@ -9,4 +9,5 @@ edition = "2018" | |||
|
|||
[dependencies] | |||
num-traits = { version = "0.2", default-features = false } | |||
integer-sqrt = "0.1" |
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.
So this is independent of the num-traits
feature?
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.
Technically it could have been, but it's rather not useful by its own. E.g. see https://github.com/paritytech/substrate/blob/d8b3fce28513169d8ee1315dd9a4cd92d95753cc/primitives/arithmetic/src/traits.rs#L33-L51
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.
LGTM but I also have not looked deeply into the algos used here.
Closes #551.
The algorithm implemented is the same as in theinteger-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?