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: T/isPowerOf2 #109

Open
oscbyspro opened this issue Oct 4, 2024 · 1 comment
Open

Add: T/isPowerOf2 #109

oscbyspro opened this issue Oct 4, 2024 · 1 comment
Labels
addition oh, so shiny! brrr such code, much wow documentation scribbles n' doodles!

Comments

@oscbyspro
Copy link
Owner

The following models can and/or should implement isPowerOf2.

  • BinaryInteger
  • Count
  • DataInt
  • DataInt.Body
  • MutableDataInt
  • MutableDataInt.Body
  • Shift

I want at least Count/isPowerOf2 for documentation purposes.

@oscbyspro oscbyspro added addition oh, so shiny! brrr such code, much wow labels Oct 4, 2024
@oscbyspro
Copy link
Owner Author

oscbyspro commented Oct 4, 2024

Also, this expression is faster than bit-counting (for small systems integers):

(x > 0) && (x & (x &- 1) == 0)

@oscbyspro oscbyspro added the documentation scribbles n' doodles! label Oct 4, 2024
@oscbyspro oscbyspro added this to the Ultimathnum 0.11.0 milestone Oct 4, 2024
oscbyspro added a commit that referenced this issue Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition oh, so shiny! brrr such code, much wow documentation scribbles n' doodles!
Projects
None yet
Development

No branches or pull requests

1 participant