(11-10-2022, 01:46 PM)a740g Wrote: I have discovered that the following snippet in QBJS outputs different results compared to QB64-PE.
Code: (Select All)
Print 10 + 20
Print 10 Or 20
In QB64-PE, it prints
30
30
And in QBJS, it prints
30
10
This is always going to be a pain in BASIC only because "OR" the
conditional operator was never distinguished cleanly from "OR" the
logical operator. For example in C you know it's "||" for the former and a single pipe for the latter. It's distinguishable in Purebasic with the word for conditional and the symbol for logical. But for QB64(PE) and whatever made like M$'s brand of BASIC, and other such dialects, we'll have to deal with the interpreter trying to figure out what is conditional and what is logical, without it needing to be in an "IF" statement. Attempts were made, I'm sure to try to force the conditional thing only in "IF" but many programmers resisted, so it is the way it is.
Anyway the solution should be use "&" for "AND" and "|" for "OR", in an example such as this one, and leave the words for conditional comparison. But it won't be done because "I can't run it in QBasic now and what am I going to do?"
Another thing is that arithmetic and logic don't interlock that well because the former tends to assume base-10 while the latter is base-2, and we're trying to write everything in base-10.
I ninja'ed
@vince who provided a good solution. Good to know QBJS is flexible enough!
EDIT: Used incorrect terms, "logical" should be "bitwise", and "conditional" might be the same as "logical" but otherwise everything here is correct.