Bitwise operations: Difference between revisions

Content added Content deleted
(→‎{{header|AppleScript}}: Added a mathematical option.)
m (added solution for autoit)
Line 1,868: Line 1,868:
MsgBox % "a >> b: " . a >> b ; arithmetic right shift
MsgBox % "a >> b: " . a >> b ; arithmetic right shift
}</lang>
}</lang>

=={{header|AutoIt}}==
No arithmetic shift.
<lang AutoIt>bitwise(255, 5)
Func bitwise($a, $b)
MsgBox(1, '', _
$a & " AND " & $b & ": " & BitAND($a, $b) & @CRLF & _
$a & " OR " & $b & ": " & BitOR($a, $b) & @CRLF & _
$a & " XOR " & $b & ": " & BitXOR($a, $b) & @CRLF & _
"NOT " & $a & ": " & BitNOT($a) & @CRLF & _
$a & " SHL " & $b & ": " & BitShift($a, $b * -1) & @CRLF & _
$a & " SHR " & $b & ": " & BitShift($a, $b) & @CRLF & _
$a & " ROL " & $b & ": " & BitRotate($a, $b) & @CRLF & _
$a & " ROR " & $b & ": " & BitRotate($a, $b * -1) & @CRLF )
EndFunc</lang>
{{out}}

<pre>255 AND 5: 5
255 OR 5: 255
255 XOR 5: 250
NOT 255: -256
255 SHL 5: 8160
255 SHR 5: 7
255 ROL 5: 8160
255 ROR 5: 63495</pre>


=={{header|AWK}}==
=={{header|AWK}}==