AND and OR

Previous topic - Next topic

Thunor

Hi

I saw your GP2X competition so I thought I'd try GLBasic :)

I have found the documentation (via Help) for AND and OR to be rather confusing. The documentation examples are using AND and OR as logical and bitwise operators, when in fact they only work as logical operators with bAND and bOR being responsible for bitwise operations.

Documentation for AND and OR :-
Quotea# = b# AND c#
a# = b# OR c#

Binary operators. Mostly used for IF expressions.

AND:

Binary code of b#: 00100010
Binary code of c#: 00100100
Binary code of a#: 00100000
Only bits that are available in b# AND c# will be set in a#.

OR:

Binary code of b#: 00100010
Binary code of c#: 00100100
Binary code of a#: 00100110
All bits that are available in b# OR c# will be set in a#.
My GLBasic test results :-

133 AND 0x7F = 1 (this is returning TRUE so it is LOGICAL AND)
bAND(133, 0x7F) = 5 (this is the result of a bitwise operation)
5 OR 0x80 = 1 (this is returning TRUE so it is LOGICAL OR)
bOR(5, 0x80) = 133 (this is the result of a bitwise operation)

So therefore in GLBasic, AND and OR are exclusively LOGICAL as far as I can tell. a# will only ever be 0 or 1 in your examples above. No other bits will be set.

Regards

Kitty Hello

Thank you. The docs are wrong.