GLBasic Benutzerhandbuch

Main sections

bAND()

num% = bAND(num1%, num2%)
num% = bAND(num1%, num2%)
num% = bOR(num1%, num2%)
num% = bXOR(num1%, num2%)
num% = bNOT(num1%)



Führt boolsche Operationen an Ganzzahlwerten aus. Die Größe der Zahlen ist dabei 32 Bit.

bAND:
Bitmuster num1%: 0010010
Bitmuster num2%: 0010100
Bitmuster num%: 0010000
Jedes Bit, das in num1% UND num2% vorhanden ist wird 1, alle anderen 0.

bOR:
Bitmuster b%: 0010010
Bitmuster c%: 0010100
Bitmuster a%: 0010110
Jedes Bit, das in b% ODER c% vorhanden ist wird 1, alle anderen 0.


Beispiel:
 
a%=0
b%=5
IF a>0 OR b>0 THEN PRINT "a>0 OR b>0", 100, 100

a=125000
lowbyte=a AND 0x00FF
hibyte= a AND 0xFF00
SHOWSCREEN
MOUSEWAIT




Beispiel:
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

See also...