PDA

View Full Version : XOR result different with PC application



Pic2008
- 26th January 2009, 04:08
In Picbasic Pro,

a var word
b var word
c var word


c = a ^ b

But using PC to calculate XOR between a and b, I got a different value than c above.

In both of these cases, when I XOR the result back with b, I can get back a.

Any idea?

Charles Linquis
- 26th January 2009, 04:51
Because "^" is a PBP command for a BITWISE (bit-by-bit) exclusive or. The PC is using a LOGICAL exclusive or. To get the same result as the PC, use the "^^" or XOR PBP commands.

Darrel Taylor
- 26th January 2009, 04:56
c = a ^ b

On a PC, that means a to the power of b.