Leap years are divisible by four of course – but it's a little more complicated than that

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