I'm a noob at C programming and I have a line of code
"P5_0^=1;"
which basically toggles an LED on a board I'm using when a switch is pressed.
Can someone explain to me what it is the ^ symbol!
I'm a noob at C programming and I have a line of code
"P5_0^=1;"
which basically toggles an LED on a board I'm using when a switch is pressed.
Can someone explain to me what it is the ^ symbol!
^ is bitwise exclusive or (called xor for short). Every bit in a ^ b is unset if the corresponding bits in a and b are equal, and set if they are unequal.
Like all operator-assign operators, "a ^= b" has the same net effect as "a = a ^ b".
Like all bitwise operators, both operands for ^ have to be of integral type. Preferably unsigned, since the result is undefined for signed types with negative values.