Page 1 of 1

AND / OR of Numeric Values?

Posted: Sun May 18, 2025 7:19 pm
by t0nyt
I'm trying to convert my I2C code from BBC BASIC to QL BASIC, but have hit a problem (there's probably others!)

I need to AND and OR numeric values, but in QL BASIC AND, for instance, is a comparison so always returns 1 (or 0 I guess)

Is there anyway in QL Basic to perform arithmetic AND/OR please?

e.g. L=((C*16) AND 250) OR 9, just returns 1 regardless of the value of C

Has been a long time since I used BASIC for anything other than basic stuff

Many thanks

Re: AND / OR of Numeric Values?

Posted: Sun May 18, 2025 7:38 pm
by tofro
SuperBASIC has specific boolean operators

&& for AND
|| for OR
^^for XOR

The logical operators do not operate bit-wise, but consider everything that evaluates to "0" as FALSE, and everything else as TRUE.

Re: AND / OR of Numeric Values?

Posted: Sun May 18, 2025 7:39 pm
by t0nyt
tofro wrote: Sun May 18, 2025 7:38 pm SuperBASIC has specific boolean operators

&& for AND
|| for OR
^^for XOR
Many thanks!

Re: AND / OR of Numeric Values?

Posted: Mon May 19, 2025 1:44 am
by ql_freak
For operators (IMHO work all also with the Artithmetic Stack [RI-stack] not just in SuperBASIC) see the "Concepts" section of the QL User Guide "Operators".

p.s.: AFAIK == compares strings case independently (that not documented in the User Guide, at least not in the English one).