Repository navigation
London | 2026-SDC-Nov | Vitalii Kmit | Sprint 1 | Number systems exercises #699
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
Open
Vitalii-code
wants to merge
3
commits into
CodeYourFuture:main
Choose a base branch
from
Vitalii-code:number-systems
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,16 +7,37 @@ The goal of these exercises is for you to gain an intuition for binary numbers. | |
| The answers to these questions will require a bit of explanation, not just a simple answer. | ||
|
|
||
| Q16: How can you test if a binary number is a power of two (e.g. 1, 2, 4, 8, 16, ...)? | ||
| Answer: | ||
|
|
||
| when the numbers of zeroes and ones are the same? | ||
|
|
||
| Answer: It has to either be 1 in binary or 1 followed by however many zeroes. For example 1000, 1, 10 are all a power of two | ||
|
|
||
| Q17: If reading the byte 0x21 as an ASCII character, what character would it mean? | ||
| Answer: | ||
| 0b - binary | ||
| 0x - hexadecimal | ||
|
|
||
| I looked up the ascii table and it was ! | ||
|
|
||
| Answer: ! | ||
|
|
||
| Q18: If reading the byte 0x21 as a greyscale colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? | ||
| Answer: | ||
|
|
||
| Answer: Should be somewhere between completely black and dark grey as the value is 33 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're on the right track. Could you be more specific? The Part 2 intro asks for an explanation, so what does the greyscale section say about how values map to shades? Where does 33 sit on that scale? |
||
|
|
||
| Q19: If reading the bytes 0xAA00FF as a sequence of three one-byte decimal numbers, what decimal numbers would they be? | ||
| Answer: | ||
|
|
||
| FF = 15*16^1 + 15*16^0 | ||
| AA = 10*16^1 + 10*16^0 | ||
|
|
||
| AA 00 FF | ||
| 170 0 255 | ||
|
|
||
| Answer: 170 0 255 | ||
|
|
||
| Q20: If reading the bytes 0xAA00FF as an RGB colour, as described in "Approaches for Representing Colors and Images", what colour would it mean? | ||
| Answer: | ||
|
|
||
| 170/255*100 = 66 | ||
| 0/255*100 = 0 | ||
| 255/255*100 = 100 | ||
|
|
||
| Answer: 66% Red, 0% Green and 100% Blue so its purple | ||
Oops, something went wrong.
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.
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.
Your answer of 8 bits is right.
The formula 2^n+1 doesn't quite match your reasoning, though. How many different numbers are there from 0 to 255 inclusive? What's the smallest power of 2 that gives you that many?