Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!codas!peora!ucf-cs!usfvax2!jc3b21!fgd3 From: fgd3@jc3b21.UUCP (Fabbian G. Dufoe) Newsgroups: net.lang.c Subject: Re: Calendar Functions (simpler lea Message-ID: <467@jc3b21.UUCP> Date: Mon, 29-Sep-86 13:27:26 EDT Article-I.D.: jc3b21.467 Posted: Mon Sep 29 13:27:26 1986 Date-Received: Tue, 30-Sep-86 14:42:59 EDT References: <34@vianet.UUCP> <86900058@haddock> Organization: St. Petersburg Jr. College, St. Petersburg FL Lines: 26 In article <86900058@haddock>, karl@haddock writes: > > vianet!devine (Bob Devine) writes: > >Dave Lewis writes: > >> if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) > > > >While this works, it is overkill. Unless you believe that your > >code will make it to the year 2100, a simple test for divisibility > >by 4 is sufficient. It is particularly galling to see a correct algorithm criticized as overkill when it is as simple and short as the above code segment. There may be a justification for writing code that only works part of the time if the fix is costly and difficult. However, it should be a general rule that an algorithm which works in all cases is preferred over one that only works in most cases. Instead of panning someone's code because he has written it more correctly, one should adopt the improved algorithm with gratitude. Fabbian Dufoe 350 Ling-A-Mor Terrace South St. Petersburg, Florida 33705 813-823-2350 UUCP: ...akgua!akguc!codas!peora!ucf-cs!usfvax2!jc3b21!fgd3