Bitwise operations: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36, explicit :prototype) |
(add RPL) |
||
Line 5,360: | Line 5,360: | ||
. "Bitwise rotation is not natively supported" |
. "Bitwise rotation is not natively supported" |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|RPL}}== |
|||
≪ { AND OR XOR NOT SL SR ASR RL RR } → a b ops |
|||
≪ {} 1 ops SIZE '''FOR''' j |
|||
a →STR " " + '''IF''' j 3 ≤ '''THEN''' b →STR + " " + '''END''' |
|||
ops j GET →STR 2 OVER SIZE 1 - SUB + " -> " + |
|||
a j 3 ≤ b IFT ops j GET EVAL →STR + + |
|||
'''NEXT''' |
|||
≫ ≫ ‘'''BITOPS'''’ STO |
|||
{{out}} |
|||
<pre> |
|||
{ "# 355h # 113h AND -> # 111h" |
|||
"# 355h # 113h OR -> # 357h" |
|||
"# 355h # 113h XOR -> # 246h" |
|||
"# 355h NOT -> # FCAAh" |
|||
"# 355h SL -> # 6AAh" |
|||
"# 355h SR -> # 1AAh" |
|||
"# 355h ASR -> # 1AAh" |
|||
"# 355h RL -> # 6AAh" |
|||
"# 355h RR -> # 81AAh" } |
|||
</pre> |
|||
Operations made with a word size set at 16 bits. |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<syntaxhighlight lang="ruby">def bitwise(a, b) |
<syntaxhighlight lang="ruby">def bitwise(a, b) |
||
Line 5,386: | Line 5,408: | ||
a >> b : 1 0000000000000001 |
a >> b : 1 0000000000000001 |
||
</pre> |
</pre> |
||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
<syntaxhighlight lang="rust">fn main() { |
<syntaxhighlight lang="rust">fn main() { |