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

sqrt hangs on some inputs #32

Closed
devast8a opened this issue Oct 28, 2023 · 3 comments
Closed

sqrt hangs on some inputs #32

devast8a opened this issue Oct 28, 2023 · 3 comments

Comments

@devast8a
Copy link

For some inputs dec64_sqrt can enter an infinite loop where it will not converge on a result and will instead oscillate between two values forever. It seems to be related to rounding behavior within dec64_divide. Printing both the coefficient and the exponent of progress, we get the following log from dec64_sqrt(dec64_make(36040, 0))

9011000000000000 -12
4507499778049051 -12
22577476706966965 -13
11368552409916279 -13
5842783632731283 -13
3229806454536597 -13
2172831395833602 -13
19157483389377885 -14
18984987616317365 -14
1898420397630861 -13
18984203960134855 -14
1898420396013486 -13
18984203960134855 -14
1898420396013486 -13
18984203960134855 -14
1898420396013486 -13
18984203960134855 -14
1898420396013486 -13
18984203960134855 -14
1898420396013486 -13
...
@douglascrockford
Copy link
Owner

So what is your fix?

@devast8a
Copy link
Author

Not sure, bounding the loop might be acceptable in the short term. In the long term, probably adopting another algorithm.

@douglascrockford
Copy link
Owner

Please submit a fix.

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

No branches or pull requests

2 participants