1. Is Year Leap

Is a year a leap year?  The following Euphoria
function will tell you.

I converted the original C routine to Euphoria.
It is interesting to note that the year 2000 will
be a leap year.

Larry Gregg

-- SNIP ----------------------------------------------------------------

global function isyearleap(integer year)
--  Returns 1 if year is a leap year, 0 otherwise.
--  Source:  "Practical Algorithms for Programmers"
--  By:  Andrew Binstock and John Rex

   if not remainder(year,4) = 0 then       --  if year not difisible by 4
      return 0                             --  it's not leap
   end if
   if year < 1582 then                     --  all years divisible by 4 were
      return 1                             --  leap prior to 1582
   end if
   if remainder(year,100) != 0 then        --  if year divisible by 4,
      return 1                             --  but not by 100, its leap
   end if
   if not remainder(year,400) = 0 then     --  if year divisible by 100,
      return 0                             --  but not by 400, it's not leap
   else
      return 1                             --  if divisible by 400, it's leap
   end if
end function


-- SNIP ----------------------------------------------------------------
--  And to exercise the function:

integer year, rc

year = 1581
rc = isyearleap(year)
printf(1,"\nYear=%4d, is leap year? %1d",year&rc)

year = 1582
rc = isyearleap(year)
printf(1,"\nYear=%4d, is leap year? %1d",year&rc)

year = 1949
rc = isyearleap(year)
printf(1,"\nYear=%4d, is leap year? %1d",year&rc)

year = 1964
rc = isyearleap(year)
printf(1,"\nYear=%4d, is leap year? %1d",year&rc)

for i = 1200 to 2100 by 100 do
   year = i
   rc = isyearleap(year)
   printf(1,"\nYear=%4d, is leap year? %1d",year&rc)
end for

new topic     » topic index » view message » categorize

2. Re: Is Year Leap

>year = 1581
>rc = isyearleap(year)
>printf(1,"\nYear=%4d, is leap year? %1d",year&rc)
>
>year = 1582
>rc = isyearleap(year)
>printf(1,"\nYear=%4d, is leap year? %1d",year&rc)
>
>year = 1949

Just one comment on calandars, not all of the world was on
the same calander until 1753, so the same event, say some
thing wide spread like a volcano eruption, can be found
recorded as happening on diffrent days/dates.

I believe Britan was the last hold out because the "pesants"
thought they where going to be cheated out of 11 days wages
if the calander was updated.

Some popular programs, like early versions of Lotus, forgot
that years divisable by 400 are leap years, like 2000, as
you pointed out.   One more thing, the "New Malenia" starts
on 2001, NOT 2000...

--
For information on any of the following check out my WEB site at:
    http://www.execpc.com/~bpaddock/ or http://www.usachoice.net/bpaddock
Chemical Free Air Conditioning/No CFC's, Chronic Pain Relief, Electromedicine,
Electronics, Explore!, Free Energy, Full Disclosure, KeelyNet, Matric Limited,
Neurophone, Oil City PA, Philadelphia Experiment.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu