Bit and, or : Binary number « Number « Ruby






Bit and, or

(0b1010 & 0b1100).to_s(2)  # => "1000"

(0b1010 | 0b1100).to_s(2)  # => "1110"
(0b1010 ^ 0b1100).to_s(2)  # => "110"

 








Related examples in the same category

1.Binary number with 0b
2.Binary bit shift left and right
3.1 || 2 && nil