Because:
1. I tested it, it returned 0.
2. Bitwise AND compares what the two parts have in common.
For example, We have 64(bit 7) and 32(bit 6) If we were to use bitwise AND on these. The result would be as follows:
Code:
64 32
1 0 0 =0
2 0 0 =0
4 0 0 =0
8 0 0 =0
16 0 0 =0
32 0 1 =0
64 1 0 =0
128 0 0 =0
=0
If on the other hand they would have something in common. Like 64(bit 7) and 96(bit 6 and 7) the result would be as follows:
Code:
64 96
1 0 0 =0
2 0 0 =0
4 0 0 =0
8 0 0 =0
16 0 0 =0
32 0 1 =0
64 1 1 =64
128 0 0 =0
=64
Compare this to the bitwise OR which basically adds up all the 1's into one result.
Code:
64 96
1 0 0 =0
2 0 0 =0
4 0 0 =0
8 0 0 =0
16 0 0 =0
32 0 1 =32
64 1 1 =64
128 0 0 =0
=96
This is why you add with |=. Both sides will combine all the activated(or whatever it's called? All the "1") bits into one larger array.
This is also why you check if a variable contains a certain bit with & because it will only return what both sides have in common.
__________________