Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
13
Task/Bitwise-operations/Ruby/bitwise-operations.rb
Normal file
13
Task/Bitwise-operations/Ruby/bitwise-operations.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
def bitwise(a, b)
|
||||
form = "%1$7s:%2$6d %2$016b"
|
||||
puts form % ["a", a]
|
||||
puts form % ["b", b]
|
||||
puts form % ["a and b", a & b]
|
||||
puts form % ["a or b ", a | b]
|
||||
puts form % ["a xor b", a ^ b]
|
||||
puts form % ["not a ", ~a]
|
||||
puts form % ["a << b ", a << b] # left shift
|
||||
puts form % ["a >> b ", a >> b] # arithmetic right shift
|
||||
end
|
||||
|
||||
bitwise(14,3)
|
||||
Loading…
Add table
Add a link
Reference in a new issue