Leap year check using bitwise operators (amazing speed)
Someone on JSPerf dropped an amazingly fast implementation for checking leap years of the ISO calendar (link: Odd bit manipulations ): function isLeapYear(year) { return !(year & 3 || year & 15 && !(year % 25)); } Using Node.js, I quickly checked it against two other one-liner implementations I know. function isLeapClassic(y) { return (y % 4 == 0) && !(y % 100 == 0) || (y % 400 == 0); } function isLeapXOR(y) { return (y % 4 == 0) ^ (y % 100 == 0) ^ (y % 400 == 0); } function isLeapBitwise(y) { return !(y & 3 || y & 15 && !(y % 25)); } //quick'n'dirty test on a small range! //works with