Created
September 2, 2013 17:54
-
-
Save allouis/6415516 to your computer and use it in GitHub Desktop.
Bitwise stuff
This file contains 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
// true to 0, false to 1; | |
var tBool = true; | |
var fBool = false | |
tBool^1 // 0 | |
fBool^1 // 1 | |
// true to 1, false to 0; | |
var tBool = true; | |
var fBool = false; | |
tBool^0 // 1 | |
fBool^0 // 0 | |
// true to 1, false to -1; | |
var tBool = true; | |
var fBool = false; | |
(tBool^1)*-1|1 // 1 | |
(fbool^1)*-1|1 // -1 | |
// true to 0, false to -1; | |
var tBool = true; | |
var fBool = false | |
(tBool^1)*-1 // 0 | |
(fBool^1)*-1 // -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment