Tutorial by Examples: bitwise

Swift Bitwise operators allow you to perform operations on the binary form of numbers. You can specify a binary literal by prefixing the number with 0b, so for example 0b110 is equivalent to the binary number 110 (the decimal number 6). Each 1 or 0 is a bit in the number. Bitwise NOT ~: var number...
Prefix bitwise operators Bitwise operators are like logical operators but executed per bit rather than per boolean value. // bitwise NOT ~: sets all unset bits and unsets all set bits printf("%'06b", ~0b110110); // 001001 Bitmask-bitmask operators Bitwise AND &: a bit is set onl...
All of the logical operators in VBA can be thought of as "overrides" of the bitwise operators of the same name. Technically, they are always treated as bitwise operators. All of the comparison operators in VBA return a Boolean, which will always have none of its bits set (False) or all of...
Instead of this (unfortunately too often seen in the real code) "masterpiece": function isEven(n) { return n % 2 == 0; } function isOdd(n) { if (isEven(n)) { return false; } else { return true; } } You can do the parity check much more effecti...
var a = 11, b = 22; a = a ^ b; b = a ^ b; a = a ^ b; console.log("a = " + a + "; b = " + b);// a is now 22 and b is now 11

Page 2 of 2