number1 AND number2

In BASIC all logic operators are context sensitive.  The default is to perform a bitwise operation on 32 bit numbers.  So that

number1 = &H55555555
number2 = &H33333333
print HEX(number1 AND number2)

Result is 11111111.  The function HEX (param) returns a string representing the hex value param.

But is the context includes a comparison then the AND operation becomes a logical operation

IF number1 > 5 AND number2 > 5 THEN statement1

So if the 2 conditions are TRUE then statement1 is executed.

If you are going to mix logical and bitwise operators then use () in the expression to evaluate the bitwise operations first, see the example below.


if (x and y)=&H11 and x>y then print "OK" 

' This will print OK

Differences from other BASICs

See also