Bitwise operations: Difference between revisions

Line 623:
PRINT "a SHR b (logical) = "; u SHR b
END SUB</lang>
 
==={{header|Commodore BASIC}}===
Commodore BASIC V2.0 does not have '''XOR''', '''left shift''', '''right shift''', '''right arithmetic shift''', '''left rotate''', and '''right rotate''' operators. In this implementation the '''XOR''' operation is done with an equivalent formula.
 
<lang basic>10 INPUT "A="; A
20 INPUT "B="; B
30 PRINT "A AND B =" A AND B :rem AND
40 PRINT "A OR B =" A OR B :rem OR
50 PRINT "A XOR B =" (A AND(NOT B))OR((NOT A)AND B) :rem XOR
60 PRINT "NOT A =" NOT A :rem NOT</lang>
{{in}}
<pre>A=? 2
B=? 6</pre>
{{out}}
<pre>A AND B = 2
A OR B = 6
A XOR B = 4
NOT A =-3
</pre>
 
==={{header|Sinclair ZX81 BASIC}}===
Anonymous user