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(binary cheatsheet): corrected bit shift direction to set Kth bit #671

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
fix(binary cheatsheet): corrected bit shift direction to set Kth bit
  • Loading branch information
andresanches committed Oct 10, 2024
commit 0e337633db9621075519db804daf47d88e4673aa
2 changes: 1 addition & 1 deletion apps/website/contents/algorithms/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Some helpful utility snippets:
| Technique | Code |
| --- | --- |
| Test k<sup>th</sup> bit is set | `num & (1 << k) != 0` |
| Set k<sup>th</sup> bit | <code>num &#124;= (1 &gt;&gt; k)</code> |
| Set k<sup>th</sup> bit | <code>num &#124;= (1 &lt;&lt; k)</code> |
| Turn off k<sup>th</sup> bit | `num &= ~(1 << k)` |
| Toggle the k<sup>th</sup> bit | `num ^= (1 << k)` |
| Multiply by 2<sup>k</sup> | `num << k` |
Expand Down