cak3g@astsun9.astro.Virginia.EDU (Colin Klipsch) (09/30/90)
In article <4404@catfish11.UUCP> yedinak@motcid.UUCP (Mark A. Yedinak) writes: >johnb@srchtec.UUCP (John Baldwin) writes: >: (Stan Brown, Oak Road Systems) writes: > >:|In article <24700010@sunc1>, mccaugh@sunc1.cs.uiuc.edu writes: >:|> Ordinarily, a leap-year is a multiple of four, so that--given leap-year y-- >:|> (y%4 == 0) ought to indicate if y designates a leap-year. > >:|Bzzzzzt! Nope, but thanks for playing. Vanna has lovely gifts for you. To be nitpicky to the point of nausea, I will point out that the rule for deciding leap years has FOUR conditions, not three. A correct algorithm is: #define FALSE 0 #define TRUE 1 int is_leap_year(int year) { if (year%4000 == 0) return FALSE; else if (year%400 == 0) return TRUE; else if (year%100 == 0) return FALSE; else if (year%4 == 0) return TRUE; else return FALSE; } With the addition of the divisible-by-4000 condition, the Gregorian calendar is now accurate to one day in 20,000 years. (Assuming its term of use lasts long enough for the rule to be practiced, which I doubt!) Source: _Exploration of the Universe_, G. Abell -------------------------------------------------------------------------- "May the forces of evil become confused on the way to your house." -- George Carlin Bemusedly, | Disclaimers: Colin Klipsch | Not guaranteed to fulfill any purpose, Property of UVa Ast. Dept. | express or implied. Contents may have Charlottesville, Virginia | settled during shipping. Not rated. May cak3g@virginia.edu | cause drowsiness. Use before 29-Feb. ____________________________/ \___________________________________________
henry@zoo.toronto.edu (Henry Spencer) (09/30/90)
In article <1990Sep30.013852.8764@murdoch.acc.Virginia.EDU> cak3g@astsun9.astro.Virginia.EDU (Colin Klipsch) writes: > if (year%4000 == 0) return FALSE; >With the addition of the divisible-by-4000 condition, the Gregorian >calendar is now accurate to one day in 20,000 years... My recollection is that the leap-millenium rule has never been formally adopted by religious or political authorities, so it is *not* part of the Gregorian calendar at this time. (We've got a little while left before we need a decision, after all... :-)) -- Imagine life with OS/360 the standard | Henry Spencer at U of Toronto Zoology operating system. Now think about X. | henry@zoo.toronto.edu utzoo!henry
manning@nntp-server.caltech.edu (Evan Marshall Manning) (10/01/90)
cak3g@astsun9.astro.Virginia.EDU (Colin Klipsch) writes: >int is_leap_year(int year) >{ > if (year%4000 == 0) return FALSE; > else if (year%400 == 0) return TRUE; > else if (year%100 == 0) return FALSE; > else if (year%4 == 0) return TRUE; > else return FALSE; >} All other things being equal, I've got to vote for the versions that make the tests most likely to be decisive first. Years like 1990 will have to undergo all of the tests above. *************************************************************************** Your eyes are weary from staring at the CRT for so | Evan M. Manning long. You feel sleepy. Notice how restful it is | is to watch the cursor blink. Close your eyes. The |manning@gap.cco.caltech.edu opinions stated above are yours. You cannot | manning@mars.jpl.nasa.gov imagine why you ever felt otherwise. | gleeper@tybalt.caltech.edu
karl@haddock.ima.isc.com (Karl Heuer) (10/02/90)
In article <1990Sep30.064715.15589@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >In article <1990Sep30.013852.8764@murdoch.acc.Virginia.EDU> cak3g@astsun9.astro.Virginia.EDU (Colin Klipsch) writes: >>With the addition of the divisible-by-4000 condition, the Gregorian >>calendar is now accurate to one day in 20,000 years... Interestingly, the approximation 365 + 1/4 - 1/128 is simpler, better suited to binary computation, and over four times more accurate. >My recollection is that the leap-millenium rule has never been formally >adopted by religious or political authorities, so it is *not* part of >the Gregorian calendar at this time. (We've got a little while left >before we need a decision, after all... :-)) Depends on *which* authorities. As I understand it, America and most of Europe do not use a quadrimillenium correction, but some relgious/political entities do. (No point to it, really, since the length of the year isn't sufficiently constant over that large a scale.) Also, as I've noted before, by the time it makes a difference (A.D. 4000) either the human race will be extinct, or will no longer base its fundamental units of timekeeping on the motions of an obscure planet in the slum area of the Orion Arm. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint (Followups to comp.misc.)