←back to thread

420 points gnabgib | 1 comments | | HN request time: 0.284s | source
Show context
Quenby ◴[] No.44003014[source]
Never thought a leap year check could be this interesting. Maybe low-level programmers had already discovered tricks like this long ago,they just never got written down? Feels like there’s still so much like this, hidden in old code, waiting to be rediscovered. If anyone has a collection of these kinds of techniques, I’d really love to dig into it.
replies(2): >>44003223 #>>44003465 #
1. arp242 ◴[] No.44003465[source]
Lotus 1-2-3 famously considers 1900 a leap year (carried over in Excel for compatibility), presumably because it just does the "(y & 3) != 0" check (arguably a reasonable optimisation given the hardware of the time).

I'd be surprised if someone found this solution before, as it seems both relatively difficult to find and a small optimisation.