title: Ruby: What does the snippet: (num & 1) == 0 exactly do?
body: <p>I was watching a metaprogramming video from PragProg, and Dave Thomas showed this snippet of code:</p>
  
  <pre><code>module Math
    class &lt;&lt; self
      def is_even?(num)
        (num &amp; 1) == 0 # What exactly is going on here? Particularly (num &amp; 1)
      end
    end
  end
  
  puts Math.is_even? 1 # =&gt; false
  puts Math.is_even? 2 # =&gt; true
  </code></pre>
  
  <p>Now I understand what is going on here, but I don't know what exactly is happening with the <code>(num &amp; 1)</code> part of the <code>Math.is_even?</code> class method. I know it is a bitwise operation but that is about it. Can someone explain to me what is going with that line of code? Thanks.</p>