OR ???

Blitz3D Forums/Blitz3D Programming/OR ???

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi,

'Or' is a 'bitwise operator' - it does a bitwise 'Or' of 2 integers. See Antony's link for details on how it works.

Basically, it 'merges' the bits in 2 integers, resulting in '1' bits whereever there was a '1' bit in *either* operand.

'And' is similar, only the result has a '1' where there are '1's in *both* operands.

Stuff like '<', '>', '>=' etc are themselves just 'operators', like '+', '-', '/' etc.

What they do is return a '1' if the comparison is true, or a '0' if its false, eg:

Print 5<10 ;prints 1
Print 5<3 ;prints 0

You can use bitwise 'Or' and 'And' with these results to achieve logic like:

a=15
If a<10 Or a>20
;do something.
Endif

...is the same as...
If 0 Or 0
Endif

...and you can even go...
a=10<20 ;=1