Bitwise operations: Difference between revisions
Content added Content deleted
(Added shifts to the task, added examples from Bit shifts, removed outputs from ones with shift added, many incorrect examples now exist) |
(Moved PHP shift code over) |
||
Line 264: | Line 264: | ||
print "after use integer:\n"; |
print "after use integer:\n"; |
||
print 'a << b: ', $a << $b, "\n"; # left shift |
print 'a << b: ', $a << $b, "\n"; # left shift |
||
print 'a >> b: ', $a >> $b, "\n"; # arithmetic right shift |
print 'a >> b: ', $a >> $b, "\n"; # arithmetic right shift |
||
}</perl> |
}</perl> |
||
=={{header|PHP}}== |
|||
{{incorrect|PHP}} |
|||
<php>$x = -3; |
|||
$n = 1; |
|||
echo '$x << $n: ', $x << $n, "\n"; // left shift |
|||
echo '$x >> $n: ', $x >> $n, "\n"; // arithmetic right shift</php> |
|||
=={{header|Python}}== |
=={{header|Python}}== |
||
<python>def bitwise(a, b): |
<python>def bitwise(a, b): |