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

isPowerOf2 should not return true for signed min #150

Closed
oscbyspro opened this issue Jul 11, 2023 · 0 comments
Closed

isPowerOf2 should not return true for signed min #150

oscbyspro opened this issue Jul 11, 2023 · 0 comments
Labels
bug please fix this :(
Milestone

Comments

@oscbyspro
Copy link
Owner

From oscbyspro/Numberick#32

I noticed that isPowerOf2 fails when Self.isSigned && self == min:

@inlinable public var isPowerOf2: Bool {
    self.nonzeroBitCount == 1 // ⚠️
}
@inlinable public var isPowerOf2: Bool {
    !self.isLessThanZero && self.nonzeroBitCount == 1 // ✅
}
@oscbyspro oscbyspro added the bug please fix this :( label Jul 11, 2023
@oscbyspro oscbyspro added this to the v4.0.2 milestone Jul 11, 2023
@oscbyspro oscbyspro changed the title isPowerOf2 should not return true for signed min isPowerOf2 should not return true for signed min Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug please fix this :(
Projects
None yet
Development

No branches or pull requests

1 participant