Logical operations: Difference between revisions

Content added Content deleted
(Added credits)
(→‎{{header|Commodore BASIC}}: Add XOR from BASIC 7.)
Line 602: Line 602:


==={{header|Commodore BASIC}}===
==={{header|Commodore BASIC}}===
In Commodore BASIC the "logical" operators are actually bitwise operators; to enable the proper semantics when they're used for logic, true expressions return -1 (all bits set) and false expressions return 0 (all bits clear).
In Commodore BASIC 'True' is -1 and 'False' is 0. There is no operation for 'exclusive-or'.
<lang qbasic>10 A = -1
<lang qbasic>10 A = -1
20 B = 0
20 B = 0
Line 615: Line 615:
-1
-1
0</pre>
0</pre>

{{works with|Commodore BASIC 7.0}}
Commodore BASIC version 7 for the C-128 added XOR, but it's a function, and for some reason was written to accept only unsigned (16-bit) numbers.

<lang basic>70 PRINT XOR(1, 0)</lang>

{{out}}
<pre>1</pre>


==={{header|BASIC256}}===
==={{header|BASIC256}}===