ZA | 25-SDC-July | Luke Manyamazi | Sprint 1 | Number Systems Exercises#89
Open
Luke-Manyamazi wants to merge 1 commit intoCodeYourFuture:mainfrom
Open
ZA | 25-SDC-July | Luke Manyamazi | Sprint 1 | Number Systems Exercises#89Luke-Manyamazi wants to merge 1 commit intoCodeYourFuture:mainfrom
Luke-Manyamazi wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
chinar-amrutkar
left a comment
There was a problem hiding this comment.
Have a think about the comment I added, and then we are good to go! Great work :)
|
|
||
| How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? | ||
| Answer: | ||
| Answer: by using the bitwise formula (N & (N - 1)) == 0 |
There was a problem hiding this comment.
Can you think of a simpler way of doing this?
Author
There was a problem hiding this comment.
A number is a power of two if you can keep dividing it by 2 until you reach 1, with no remainders along the way. If at any point there’s a remainder, it’s not a power of two.
Author
|
If all is well please help me mark the PR as complete. |
Author
|
@chinar-amrutkar @LonMcGregor @illicitonion kindly help to check if all is well here and please mark as complete if all is well, this is a requirement for my Launch Module application. Thank you very much. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Here's your brief as a list, based on what you've stated you've done:
I have:
Questions
Beyond these exercises, what's a practical, real-world scenario where understanding these low-level binary/hex/byte interpretations becomes critical in programming?