Reputation: 155
In an example I saw these operators (|= and &=) but it wasn't explained.
I was looking on Google about it, but I found only results related to the "classic" = operator.
So I would like to know what are these operators doing. Can somebody explain it to me ?
Upvotes: 1
Views: 172
Reputation: 19486
They perform bitwise-OR |=
operations and bitwise-AND &=
operations with the result being stored in the lValue
. They're the same as |
and &
, but store the result in the lValue
analogous to the difference between +
and +=
or -
and -=
.
Upvotes: 1
Reputation: 354406
|=
and &=
are assignment operators related to the |
(bitwise or) and &
(bitwise and) operators.
Upvotes: 1
Reputation: 62248
well &=
is the same like i+=
, in other words
x&=2
is a short form of x=x & 2
Upvotes: 0