Skip to content

Instantly share code, notes, and snippets.

@allouis
Created September 2, 2013 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allouis/6415516 to your computer and use it in GitHub Desktop.
Save allouis/6415516 to your computer and use it in GitHub Desktop.
Bitwise stuff
// 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