Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Mar 1998 19:55:58 +1000
From:      Stephen McKay <syssgm@dtir.qld.gov.au>
To:        "Jonathan M. Bresler" <jmb@FreeBSD.ORG>
Cc:        freebsd-chat@FreeBSD.ORG
Subject:   Re: y2k
Message-ID:  <199803250955.TAA13470@troll.dtir.qld.gov.au>

next in thread | raw e-mail | index | archive | help
Jonathan M. Bresler wrote:
>Swerda wrote:
>> i dont believe 2000 is a leap year

I just close my eyes and wish!

http://www.ast.cam.ac.uk/RGO/leaflets/leapyear/leapyear.html is brief, but
informative, including a bit of the history of calendars.

>> a leap year is divisible EVENLY BY 4
>> except NOT one divisible by 400
>
>	2000 is a leap year.
>
>	if  (year % 400 == 0 || 
>	    (year % 100 != 0 && year % 4 == 0))
>		printf("leap year\n");

But, of course, for that little bit of efficiency, you should code it:

	if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
	    printf("leap year\n");

so that for 3 out of 4 years only one division and comparison is done.


Stephen.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199803250955.TAA13470>