I have a variable that stores false or true, but I need 0 or 1 instead, respectively. How can I do this?
false
true
0
1
You can also add 0, use shift operators or xor:
val + 0; val ^ 0; val >> 0; val >>> 0; val << 0;
These have similar speeds as those from the others answers.