Bitwise Operators: Difference between revisions

m
Added more properties
m (Added more properties)
Line 14:
For all numbers A:
 
* <code>A & 0 = 0</code>
* <code>A & A = A</code>
* <code>A & -1 = A (remember that -1 = FF)</code>
* Every 4 binary digits of A and B can be <code>AND</code>ed separately and concatenated, and the result is the same.
Line 73 ⟶ 74:
For all numbers A:
* <code>A | 0 = A</code>
* <code>A | A = A</code>
* <code>A | -1 = -1</code>
 
 
The first property implies that if a subset of a byte is a sequence of zeroes, then <code>OR</code>ing that sequence of zeroes with any bit combination will result in the same bit combination. For example:
Line 102 ⟶ 105:
* A bit <code>XOR</code>'d with 1 will flip. A bit <code>XOR</code>'d with zero won't change.
* A bitwise <code>NOT</code> is the same as <code>XOR -1</code>.
* <code>A ^ A = 0</code>
 
 
1,489

edits