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 ?
|=
and &=
are assignment operators related to the |
(bitwise or) and &
(bitwise and) operators.
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 -=
.
well &=
is the same like i+=
, in other words
x&=2
is a short form of x=x & 2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.