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

Add: BinaryInteger/isqrt() #76

Closed
oscbyspro opened this issue Aug 28, 2024 · 2 comments
Closed

Add: BinaryInteger/isqrt() #76

oscbyspro opened this issue Aug 28, 2024 · 2 comments
Labels
addition oh, so shiny!

Comments

@oscbyspro
Copy link
Owner

I'll add some binary integer square root methods.

@oscbyspro oscbyspro added the addition oh, so shiny! label Aug 28, 2024
@oscbyspro oscbyspro added this to the Ultimathnum 0.9.0 milestone Aug 28, 2024
oscbyspro added a commit that referenced this issue Aug 29, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Aug 29, 2024

Hm. I'm not sure the extensions on Nonzero<T> are worth the headache. I don't really want to juggle guarantee types (#62). It might be better to just pick the most lenient set that promises nonoptional results and stick with it. In this case, that would be Natural<T>. It's an extra is-zero check, but it's also a more straightforward type conversion story. Natural<T> might be the best fit even if I had some kind of Nonzero<Natural<T>> type (#78), in part because the Nonzero<T> hoist could become redundant if I change the algorithm.

@oscbyspro
Copy link
Owner Author

oscbyspro commented Aug 29, 2024

The internal UnsignedInteger.isqrt(natural: Nonzero<Self>) helper method approach is a bit faster, for reasons unclear to me, even when the is-zero check is performed. But, getting the function count down to 4 (from 6) is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny!
Projects
None yet
Development

No branches or pull requests

1 participant