精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>C/C++>>一般性编程问题>>i teach u what LEAP YEARS are

主题:i teach u what LEAP YEARS are
发信人: crazyjava()
整理人: wenbobo(2002-12-24 09:18:33), 站内信件
Leap Years


If you can remember back to what you were taught in school ... 

     A leap year is a year where the number of that year can be 
     divided by four without leaving any remainder.

However, that is not the whole truth of the matter. 

1) How leap years work

Every year ( ignoring leap years for the time being ) is nominally 
365 days long. That means it takes 365 days for the Earth to orbit
around the Sun and get back to where it started from. 

Unfortunately it takes about 365.25 days to complete an orbit so
 every 365 days we are a litle further back than where we were 
that year ago. If this situation was allowed to continue unchecked,
after some 750 years, what is now the middle of summer would be 
the middle of winter and vice versa. 

To correct this defect we add an extra day to our year every four 
years; that is a leap year. 

Whilst our leap year every four years, conveniently defined as 
being in every year that is divisible by four without leaving a 
remainder, generally corrects the problem the oribit is not 
exactly 365.25 days thus it requires a further correction. 

This correction is provided every 100 years when a leap year 
does not occur and, further still, every four of those 100 years 
when a leap year does indeed occur. 

This means that simply dividing the number of the year by four 
and checking there is no remainder is not a correct way of 
determining if a year is a leap year or not 

2) The full leap year rules

The full rules for calculating whether a year is a leap year or 
not are - 

    (1) If the number of the year can be divided by 400 without 
        leaving any remainder; it is a leap year

                      otherwise

    (2) If the number of the year can be divided by 100 without 
        leaving any remainder; it is not a leap year

                      otherwise

    (3) If the number of the year can be divided by four without 
        leaving any remainder; it is a leap year

                      otherwise

    (4) It is not a leap year


Failure to know or understand these complete rules are one aspect 
of the Millennium Bug that is predicted to occur in some computer
software in the year 2000 AD. 

Because 2000 AD is exactly divisible by 400 it is a leap year. If 
only the basic divide by four rule is used then, luckily, the year 
will be treated correctly as a leap year. The problem arises when 
someone has knowledge of the divide by 100 rule but not of the 
divide by 400 rule; in these cases 2000 AD will not be treated as 
a leap year which is incorrect. 

3) Were you taught the full leap year rules ?

Have the complete leap year rules come as a complete surprise or 
are they something that you were taught at school. If you were 
taught them you are, as far as I can tell, one of the lucky few. 

Everyone else, myself included, appears to have been fed the 
divide by four rule as if it were an absolute and complete 
system for determining when leap years occur. 

I was quite surprised when I discovered, quite a while ago now, 
that I had not been told the full truth and, believing that what 
I was taught was more correct, even had to check the matter in 
an encylopedia before I could accept that what I had been taught 
was simply incorrect or, at least, misleading. 

(Sources from Hippy's Happy site, edited by crazyjava)

--
孤身走我路...
其实,路,两个人一起走比一个人要好。
email: [email protected]

※ 修改:.crazyjava 于 May  6 04:10:46 修改本文.[FROM: 139.87.93.171]
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 139.87.93.171]

[关闭][返回]