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
AND / OR of Numeric Values?
Re: AND / OR of Numeric Values?
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.
&& 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.
Last edited by tofro on Sun May 18, 2025 7:40 pm, edited 1 time in total.
ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Re: AND / OR of Numeric Values?
Many thanks!tofro wrote: Sun May 18, 2025 7:38 pm SuperBASIC has specific boolean operators
&& for AND
|| for OR
^^for XOR
Re: AND / OR of Numeric Values?
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).
p.s.: AFAIK == compares strings case independently (that not documented in the User Guide, at least not in the English one).
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
