An example code in a class reading had the following code:
// adjustSpacing will set bits in the spacing word to indicate the
// type of spacing adjustment to be done, LEADING OR TRAILING.
public void adjustSpacing(int spacingValue)
spacing |= spacingValue;
The bitwise & operator performs a bitwise AND operation.
The bitwise ^ operator performs a bitwise exclusive OR operation.
The bitwise | operator performs a bitwise inclusive OR operation.
From what I can tell, the |= result will have all of the ones from both A & B;
Yes. If either of A or B has a 1 for a particular bit, or, if both have 1, then the resulting bit is 1.
the &= result will have only the ones present in both.
Again, YES. Only if both A and B has 1 in their bit, then the resulting bit would be 1; else 0.