Created
December 16, 2022 07:42
-
-
Save n3r0bi0m4n/259064129a0c01ff3d7e2329f5a809b2 to your computer and use it in GitHub Desktop.
take last N bits
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
| function takeLastNBits(n, bits) { | |
| console.log(n.toString(2)) | |
| console.log((n&((1<<bits)-1)).toString(2).padStart(bits, 0)) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment