bool x,j;
x=x+j;
This statement automatically promotes x
and j
to type int
before adding them. Then the assignment converts back to bool
in the usual way: 0
becomes false
, but any other number , including 2, becomes true
.
You can get Z_2 addition by using the ^
(xor) operator instead:
x = x^j;