Created
March 28, 2020 22:16
-
-
Save imolorhe/7328a6a43f8e2e5ecc1bbde95b67e6ed to your computer and use it in GitHub Desktop.
Revisions
-
imolorhe created this gist
Mar 28, 2020 .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,93 @@ 1 << 2 4 << 1 // bitwise left shift operator // d - 4 // b - 100 // >> n // << n => 2 ^ n 5 << 1 // 10 => 5 * (2 ^ n) 5 << 2 // 20 => 5 * (2 ^ n) 8 >> 2 // 2 // 1000 >> 10 x << n // x * (2 ^ n) // 000000001 // 000000100 << 2 // 001000000 << n // config = { dark: true, privacy: true, loggedIn: true, bookmarked: true, archived: false }; // config.dark = true; // dplba // 11110 => 30 // const d_mask = 10000; // dark // const p_mask = 01000; // privacy // const l_mask = 00100; // loggedIn // Setting to true // ----- // 11110 // | // 10000 // ----- // 11110 // Toggle // ------ // 11110 // ^ // 10000 // ----- // 01110 // _________________ // 01110 // | // 10000 // ----- // 01110 // Setting to false // ----- // 11110 // & // 01111 (~ (10000)) // ----- // 01110 => 14 // bitwise operators // AND, OR, XOR // &, |, ^ // 1 & 0 => 0 // 1 | 0 => 1 // 1 ^ 1 => 0 // 0 ^ 1 => 1 // 1 ^ 0 => 1 // 0 ^ 0 => 0 parseInt(01110001, 2); parseInt('01110001', 2); x.toString(2);