Created
January 31, 2021 23:13
-
-
Save calebkiage/51ed2f44a47ee6b87ef938e8ee2a2341 to your computer and use it in GitHub Desktop.
Revisions
-
calebkiage created this gist
Jan 31, 2021 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ const buffer = Buffer.from("9999999999", "ascii"); const mask = 15; // 00001111 let result = 0; for (let i = 0; i < buffer.length; i++) { const place = 1 * (10 ** i); const pos = (buffer.length - i) - 1; result += (buffer[pos] & mask) * place; } console.log(result);