'x&=5'
What does it mean when its like this: x&=3
What does &=
and what does the &=
means?
'x&=5'
What does it mean when its like this: x&=3
What does &=
and what does the &=
means?
Basically, x+=y
== x = x+y
[*] and same for many other operators.
This means your x&=5
is the same as x = x&5
.
So what's &
? It's a bitwise 'and'. You can read more about bitwise operators here.
&5
basically takes 3rd and 1st lowest bits (because 5 dec == 101 bin) from whatever is your x
.
Notes:
[*] The implementation isn't always the same. +=
on lists modifies the current list, rather than make a new list with the sum and assign it to the name. But the effect is the same.