The leap year algorithm explained. Divide by 4 then check to see if there’s a remainder. If remainder = 0 do the other checks. It’s a simple nested if then else statement. The new divide by 128 calculation is an unnecessary change which will create work for programmers on legacy systems.
This article titled “When is a leap year not a leap year?” was written by Alex Bellos, for The Guardian on Monday 28th February 2011 06.00 UTC Today is the last day of February. We know this because 2011 is not a leap year – because 2011 is not divisible by four. Only on years divisible by four – such as 2012 – does February have 29 days. Well, kind of. The leap year rule that has been in place since 1582 is a bit more complicated. Years that are divisible by four are leap years, with the exception of years that are divisible by 100, which are not leap years, and with the final exception of years divisible by 400, which are. This is confusing, so a British mathematician has suggested switching to a better rule, but before I get to that, this is why leap years are needed in the first place. The number of days it takes the sun to return to the same position as seen from Earth is 365.2421897. The extra day in February is used to adjust the calendar for the cumulative effect of the excess 0.2421897 of a day. If the rule is that leap years only fall on years divisible by four, as was the case for the millennium and a half before 1582, then the calendar shifts on average by about 11 minutes a year. It then only takes about a century and a half for it to be a whole day out. Under our current rule, the calendar shifts by an average of about 26 seconds a year, which means it will be one day out by about the year 4000. Better, but not perfect. (And ignoring variance in the solar year.) The following rule, devised recently by British maths brainiac Adam P Goucher, is much cleverer: years divisible by 128 are not a leap year, otherwise years divisible by four are a leap year. The 128 rule only shifts the calendar by about 0.2 seconds a year, which means it will take almost half a million years for the calendar to be a day out. That’s called forward planning.
• Alex Bellos is the author of Alex’s Adventures in Numberland
guardian.co.uk © Guardian News & Media Limited 2010 Published via the Guardian News Feed plugin for WordPress.
Thanks for subscribing to Andy Roberts blogWhen is a leap year not a leap year?
Related posts:Pub of the year award goes to a London local for first time Olympics Anish Kapoor tower hopes to attract 1m visitors a year Chinese New Year February 14th 2010

