The input data I have are bit strings, assumed to be a binary numbers, each 4 bytes:
str = "11111111010011111111111010000001"
str2 = "11000000000000000000000000000011"
And I would like to combine the two strings using a bitwise AND, like so
str & str2 #=> "11000000000000000000000000000001"
I have tried converting both strings to integers using str.to_i
but Ruby treats the input as base 10, rather than base 2:
str.to_i #=> 11111111010011111111111010000001
How can I solve this?