title: Leap year check using bitwise operators (amazing speed)
body: <p>Someone on JSPerf dropped an amazingly fast implementation for checking leap years of the ISO calendar (link: <a href="http://jsperf.com/find-leap-year/4">Odd bit manipulations</a>):</p>
  
  <pre><code>function isLeapYear(year) {
    return !(year &amp; 3 || year &amp; 15 &amp;&amp; !(year % 25));
  }
  </code></pre>
  
  <p>Using Node.js, I quickly checked it against two other one-liner implementations I know.</p>
  
  <pre><code>function isLeapClassic(y) { return (y % 4 == 0) &amp;&amp; !(y % 100 == 0) || (y % 400 == 0); }
  function isLeapXOR(y) { return (y % 4 == 0) ^ (y % 100 == 0) ^ (y % 400 == 0); }
  function isLeapBitwise(y) { return !(y &amp; 3 || y &amp; 15 &amp;&amp; !(y % 25)); }
  
  //quick'n'dirty test on a small range!
  //works with negative integers too
  for (var i = 1900; i &lt;= 2100; i++) {
      console.log(
          "year = %d,\t%d%d%d",
          i,
          isLeapClassic(i),
          isLeapXOR(i),
          isLeapBitwise(i)
      );
  }
  </code></pre>
  
  <p>It works as expected, but my problem is I can't figure how.
  I know <code>((a % b) == (a &amp; (b-1))</code> when b is power of two so <code>(year % 4) == (year &amp; 3)</code>, but <code>year &amp; 15 &amp;&amp; !(year % 25)</code> is quite hard to figure out. Can someone explain me how it works? Any reference about this implementation?</p>