Leap year check using bitwise operators (amazing speed)

后端 未结 2 1898
执笔经年
执笔经年 2020-12-08 08:39

Someone on JSPerf dropped an amazingly fast implementation for checking leap years of the ISO calendar (link: Odd bit manipulations):

function isLeapYear(yea         


        
2条回答
  •  广开言路
    2020-12-08 09:07

    If a number is divisible by 16 and divisible by 25, it's divisible by four times 25 (100) as well as 16 times 25 (400).

提交回复
热议问题