c24ee4e3cb6a164eef9219d3988f3b2a6bef2dda
3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
6 # Task: Bitwise operations
7 # SEE: <http://rosettacode.org/wiki/Bitwise_operations>
8 # Without logical right shift
9 module bitwise_operations
11 fun bitwise
(a
, b
: Int)
13 print
"a and b: { a.bin_and(b) }"
14 print
"a or b: { a.bin_or(b) }"
15 print
"a xor b: { a.bin_xor(b) }"
16 print
"not a: { a.bin_not }"
17 print
"a << b: { a << b }"
18 print
"a >> b: { a >> b }"
21 if args
.length
>= 2 then
22 bitwise
(args
[0].to_i
, args
[1].to_i
)
24 print
"Usage : ./bitwise_operations X X"