|
Bitwise operator
In C the common ones are bitwise OR | bitwise AND & and (please correct me if I'm wrong, my C book is at work) bitwise XOR ^
What the operators do is take the number in binary and perform the operation (or, and, xor) on the corresponding bits.
OR evaluates to 1 if either input is 1, 0 otherwise
AND evaluates to 1 if both inputs are 1, 0 otherwise
XOR evaluates to 1 if only 1 (not both) inputs are 1, 0 otherwise
Example:
148 | 51 -> 10010100 | 00110011 = 10110111 -> 183
148 & 51 -> 10010100 | 00110011 = 00010000 -> 16
148 ^ 51 -> 10010100 | 00110011 = 10100111 -> 167
If you take an intro to computer engineering class in college, you'll learn this within the first couple of weeks. If you have more questions ask away, we're here to help.
Mike
|