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 mostSignificantBit comment #98

Closed
oscbyspro opened this issue Apr 28, 2023 · 3 comments
Closed

Fix mostSignificantBit comment #98

oscbyspro opened this issue Apr 28, 2023 · 3 comments
Labels
bug please fix this :( documentation please write it down

Comments

@oscbyspro
Copy link
Owner

oscbyspro commented Apr 28, 2023

At some point I tried to add clarity with the following assertions:

 mostSignificantBit == words .last! .mostSignificantBit // true ⚠️
leastSignificantBit == words.first!.leastSignificantBit // true ✅

But the mostSignificantBit part is only true for multiples of UInt.bitWidth.

@oscbyspro oscbyspro added bug please fix this :( documentation please write it down labels Apr 28, 2023
@oscbyspro
Copy link
Owner Author

oscbyspro commented Apr 28, 2023

I'm unsure how valuable this property is, but I like the symmetry.

@oscbyspro
Copy link
Owner Author

oscbyspro commented Apr 28, 2023

It should really be the following, but I'm not convinced it adds clarity:

 mostSignificantBit == (self & 1 << (bitWidth - 1) != 0)
leastSignificantBit == (self & 1                   != 0)

@oscbyspro
Copy link
Owner Author

I removed that section in 967806c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug please fix this :( documentation please write it down
Projects
None yet
Development

No branches or pull requests

1 participant