Bitwise operations: Difference between revisions
Content added Content deleted
(added OpenEdge 'solution') |
No edit summary |
||
Line 645: | Line 645: | ||
i shift -3: -2 = -10b</pre> |
i shift -3: -2 = -10b</pre> |
||
=={{header|Inform 6}}== |
|||
Inform 6 has no xor or rotate operators. It also has no shift operators, although the Z-machine, its usual target architecture, does. These can be accessed with inline assembly, which is done here. |
|||
<lang Inform 6>[ bitwise a b temp; |
|||
print "a and b: ", a & b, "^"; |
|||
print "a or b: ", a | b, "^"; |
|||
print "not a: ", ~a, "^"; |
|||
@art_shift a b -> temp; |
|||
print "a << b (arithmetic): ", temp, "^"; |
|||
temp = -b; |
|||
@art_shift a temp -> temp; |
|||
print "a >> b (arithmetic): ", temp, "^"; |
|||
@log_shift a b -> temp; |
|||
print "a << b (logical): ", temp, "^"; |
|||
temp = -b; |
|||
@log_shift a temp -> temp; |
|||
print "a >> b (logical): ", temp, "^"; |
|||
]; |
|||
</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |
||