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

fix: initial guess explanation correction #67

Merged
merged 1 commit into from
Dec 25, 2021

Conversation

transmissions11
Copy link
Contributor

@transmissions11 transmissions11 commented Dec 24, 2021

i believe this explanation is incorrect, see an explanation of Newton's Method (which the babylonian method uses) in Hacker's Delight for details

Screen Shot 2021-12-24 at 2 50 11 PM

@PaulRBerg
Copy link
Owner

Great catch! I think what I had in mind when I wrote that comment is that the power of two itself if squared again, but that is obviously wrong. As per the next comment in the sqrt function:

The operations can never overflow because the result is max 2^127 when it enters this block.

The result couldn't have been maximum 2^127 if the initial guess was the least power of two greater than x.

@PaulRBerg PaulRBerg merged commit f025669 into PaulRBerg:main Dec 25, 2021
@transmissions11 transmissions11 deleted the patch-1 branch December 25, 2021 20:16
@transmissions11
Copy link
Contributor Author

transmissions11 commented Dec 25, 2021

you reversed the key change in this PR in this commit heh, was that intentional?

@PaulRBerg
Copy link
Owner

LOL 😂

Did it twice. I meant to write sqrt(x) in that commit hash. It should be deleted now, I force pushed a new version.

@transmissions11
Copy link
Contributor Author

haha all good just wanted to make sure we were on the same page! merry christmas :)

@PaulRBerg
Copy link
Owner

You too man!

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