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

colors.html #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ print num

for i in range(11):
num = num << 1
print number
print num
```

Run it, and you'll see that this is what you get:
Expand Down Expand Up @@ -86,7 +86,7 @@ print num

for i in range(11):
num = num << 1
print number
print num
```

So, about that `<<` thing. `<<` is actually an _operator_ much like `+`, `-`, `*` or `/`. However, while `+-*/` are _arithmetic operators_, `<<` is a _bitwise operator_. It is called **left shift**, and it operates on the _underlying binary representation_ of the number to the left of `<<`. What this implies is that **for every number** (`1`, `2`, `3`, `4`, ...), **there is a binary code equivalent**.
Expand Down Expand Up @@ -153,7 +153,7 @@ print num

for i in range(11):
num = num * 2
print number
print num
```

**What do you think this program outputs?** Here's a hint: remember how after we played the _2048_ game I said to think about the numbers as `2 * 2`, `2 * 4`, `2 * 8`, and so on? Lo and behold!
Expand Down
Loading