← Back to Ruby Operators

Bitwise AND Operator

The bitwise AND operator (&) is used to perform a bitwise AND operation on two numbers.

Here is an example of using the bitwise AND operator.

10 & 3 # => 2

> 10.to_s(2)
=> "1010"
> 3.to_s(2)
=> "11"
> (10 & 3).to_s(2)
=> "10"
> 0b10.to_i
=> 2

Resources