Xref: utzoo comp.sys.ibm.pc:31172 comp.sys.atari.st:17632 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cmcl2!rna!amms4!hjg From: hjg@amms4.UUCP (Harry Gross) Newsgroups: comp.sys.ibm.pc,comp.sys.atari.st Subject: Re: Will Your SW Make it to the year 2000? Message-ID: <441@amms4.UUCP> Date: 7 Jul 89 14:37:09 GMT References: <4342@druhi.ATT.COM> <381@amms4.UUCP> <382@amms4.UUCP> Reply-To: hjg@amms4.UUCP (Harry Gross) Organization: Eagle Clothes, Inc., New York, NY Lines: 49 In article <381@amms4.UUCP> I wrote: >is just a wee bit more than that stated above. Specifically, a leap year >exists if: > > 1) the year is divisible by 4 AND > 2) the year is NOT divisible by 400 > >thus, the years 1700, 1800 and 1900 were leap years, but 2000 will NOT be >a leap year, and 2100 WILL be. In article <382@amms4.UUCP> I modified that to read: >rule 2) should state: > >2) the year ends in 00 and is NOT divisible by 400 > >also, the AND at the end of rule 1) should be an OR. > >Thus: >1) the year is divisible by 4 and does NOT end in 00 OR >2) the year ends in 00 and is NOT divisible by 400 In a private message from neubauer@bsu-cs.bsu.edu (Paul Neubauer), he wrote: >You have the century years backwards! 1700, 1800, and 1900 were NOT leap >years, but 2000 will be. No flame, just a warning: check this algorithm >BEFORE you code it into something that might be around for very long. I replied to him that I was fairly certain that I had it right, but that I would check anyway. Well, I had it wrong (open mouth, insert foot, close mouth :-) Paul was right, and I _did_ have the centuries backwards. A correct test for leap year, therefore, is: if (year%4 == 0 && year%100 != 0 || year%400 == 0) printf("LEAP YEAR!"); That test comes from the K & R book, from their date conversion routine somewhere around page 103 (113?). I should have looked before I leapt :-) Sorry for the unnecessary noise, but I did want to post the correction (and the apology :-). Later, -- Harry Gross | reserved for | something really Internet: hjg@amms4.UUCP (we're working on registering)| clever - any UUCP: {jyacc, qtny, rna, bklyncis}!amms4!hjg | suggestions?