-
-
Notifications
You must be signed in to change notification settings - Fork 42
ZA | 25-SDC-July | Luke Manyamazi | Sprint 1 | Number Systems Exercises #89
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
base: main
Are you sure you want to change the base?
ZA | 25-SDC-July | Luke Manyamazi | Sprint 1 | Number Systems Exercises #89
Conversation
chinar-amrutkar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you think of a simpler way of doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
If all is well please help me mark the PR as complete. |
|
@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. |
LonMcGregor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me
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?