GLBasic User Manual

Main sections

bAND()

num% = bAND(num1%, num2%)



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

bAND:

bAND compares the binary codes for num1% and num2% for matching bits. Any corresponding bits that are set to 1 in both num1% and num2% will appear in the result.

Binary code of num1%: 00100010
Binary code of num2%: 00100100
num1% bAND num2% : 00100000


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...