GLBasic User Manual

Main sections

bXOR()

num% = bXOR(num1%, num2%)



Performs the boolean XOR operation on integer values. The numbers are 32bits in size.

bXOR:

bXOR compares the binary codes for num1% and num2% looking for differences. If the value of a binary bit in num1% differs to the corresponding binary bit in num2%, the resulting bit will be set to 1. If the bits are the same, the result will be 0.

Binary code of num1% : 00100010
Binary code of num2% : 00100100
num1% bXOR num2% : 00000110


Example:
FOR a%=0 TO 1
FOR b%=0 TO 1
x = (a+b*2)*160
PRINT "a="+a+" b="+b, x, 30

PRINT "bAND="+bAND(a, b), x, 60
PRINT "bOR ="+bOR (a, b), x, 80
PRINT "bXOR="+bXOR(a, b), x, 100
IF b=0 THEN PRINT "bNOT="+bNOT(a), x, 120
NEXT
NEXT
SHOWSCREEN
MOUSEWAIT


Output:
a=0 b=0 a=1 b=0 a=0 b=1 a=1 b=1

bAND=0 bAND=0 bAND=0 bAND=1
bOR=0 bOR=1 bOR=1 bOR=1
bXOR=0 bXOR=1 bXOR=1 bXOR=0
bNOT=-1

See also...