[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Leap year algorithm needed



check here for the explaination of leap year calculation

http://www.rog.nmm.ac.uk/leaflets/leapyear/leapyear.html

your rules are basically this (you could squash this into a compact statement,
but it might be less clear)
 Y is the year
 L is a leap year flag
A is a /4 regular year divis test - year /4 are leap (unless they are centuries)

B is a century test
C is a leap century test - century years /400 are leap years

L=0
A=Y/4
B=Y/100
C=Y/400

IF ( A=INT(A) AND B<>INT(B) ) OR (B=INT(B) AND C=INT(C)) THEN L=1

the first part tests /4 AND NOT a century
the second part test if century and /400

again, you could squish this down - but it is a start

NOTE : this is the gregorian system started in 1582 which takes the century
stuff into account
before 1582 (back to 46 BC) you may want to just check the /4 stuff

Jim Winger




IF

"Richard A. Hall" wrote:

> I need to update a Dos 3.3 program. I want the program to calculate leap
> years. Can anyone supply me with the algorithm to do this? I find it in none
> of my Basic books.
> Thank you
>
> Apple II educational software http://members.xoom.com/AV_Systems