fix(binary cheatsheet): corrected bit shift direction to set Kth bit

pull/671/head
Andre Sanches 1 month ago
parent 5dd02b1d47
commit 0e337633db

@ -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` |

Loading…
Cancel
Save