How can one specify a number as binary in gawk
?
According to the manual, gawk
interprets all numbers as decimal unless they are preceded by a 0
(octal) or by a 0x
(hexadecimal). Unlike in certain other languages, 0b
does not do the trick.
For instance, the following lines do not give the desired output (010000
or 10000
) because the values are interpreted as octal/decimal or decimal/decimal, respectively:
gawk '{print and(010000,110000)}'
0
gawk '{print and(10000,110000)}'
9488
I suspect that gawk
may not support base-2 and that a user-defined function will be required to generate binary representations.