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

implement Sqrt() #104

Merged
merged 2 commits into from
Dec 7, 2021
Merged

implement Sqrt() #104

merged 2 commits into from
Dec 7, 2021

Conversation

holiman
Copy link
Owner

@holiman holiman commented Dec 7, 2021

This PR implements Sqrt, and closes #100.

BenchmarkSqrt/single/uint256-6           1958528               603.8 ns/op             0 B/op          0 allocs/op
BenchmarkSqrt/single/uint256-6           1942036               667.9 ns/op             0 B/op          0 allocs/op
BenchmarkSqrt/single/uint256-6           1999359               607.8 ns/op             0 B/op          0 allocs/op
BenchmarkSqrt/single/uint256-6           1914327               587.4 ns/op             0 B/op          0 allocs/op
BenchmarkSqrt/single/uint256-6           2010532               610.4 ns/op             0 B/op          0 allocs/op
BenchmarkSqrt/single/big-6                539826              4824 ns/op             528 B/op          7 allocs/op
BenchmarkSqrt/single/big-6                585172              3554 ns/op             528 B/op          7 allocs/op
BenchmarkSqrt/single/big-6                353688              3529 ns/op             528 B/op          7 allocs/op
BenchmarkSqrt/single/big-6                579885              4223 ns/op             528 B/op          7 allocs/op
BenchmarkSqrt/single/big-6                625279              3426 ns/op             528 B/op          7 allocs/op

@holiman holiman requested a review from chfast December 7, 2021 08:05
@codecov
Copy link

codecov bot commented Dec 7, 2021

Codecov Report

Merging #104 (2c5b5b0) into master (488e4f1) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #104   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines         1364      1385   +21     
=========================================
+ Hits          1364      1385   +21     

for {
z2 = z2.Div(x, z1)
z2 = z2.Add(z2, z1)
{ //z2 = z2.Rsh(z2, 1) -- the code below does a 1-bit rsh faster
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is DeepSource complain about this additional block.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yeah deepsource is nitpicky. "Unnecessary block detected" - hmpf.
Do you also think it should be removed? I personally like partitioning stuff like that sometimes, for clarity.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I could move the a,b definition inside this clause to make deepsource happy

Copy link
Collaborator

Choose a reason for hiding this comment

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

I could move the a,b definition inside this clause to make deepsource happy

This is good idea.

@holiman holiman merged commit e702bda into master Dec 7, 2021
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.

feature request: sqrt
2 participants