Anonymous user
Bitwise operations: Difference between revisions
→{{header|AWK}}: gawk has compl(n) for bitwise not. OpenBSD awk also has these functions.
(→{{header|PARI/GP}}: move bitneg to lang) |
(→{{header|AWK}}: gawk has compl(n) for bitwise not. OpenBSD awk also has these functions.) |
||
Line 184:
=={{header|AWK}}==
Standard awk does not have bitwise operators. Gawk has built-in functions for many bitwise operations. No rotation of bits.
{{works with|gawk}}
<lang awk>BEGIN {
Line 195 ⟶ 194:
print n " and " p " = " and(n,p)
print n " xor " p " = " xor(n,p)
print n " << " p " = " lshift(n, p) # left shift
print n " >> " p " = " rshift(n, p) # right shift
printf "
}</lang>
[[OpenBSD]] <code>/usr/bin/awk</code> (a variant of [[nawk]]) has these same functions, with a few differences. Gawk uses 53-bit unsigned integers, but OpenBSD awk uses 32-bit signed integers. Therefore Gawk prints <code>not 11 = 0x1ffffffffffff4</code>, but OpenBSD awk prints <code>not 11 = 0xfffffff4</code>.
=={{header|BASIC}}==
|