User Tools

Site Tools


IsLeapYear Function to determine if the given year is a Leap Year on the Gregorian (western) calendar

The following is an MMBasic function to indicate that the given year is a leap year.

It simply returns a Boolean (actually an integer) of 1 if the year is leap or 0 if not.

Faster version eliminates decision making



Example Usage:

DaysInYear=365+IsLeapYear(year) If IsLeapYear(year) Then…

	Function IsLeapYear(n As Integer) As Integer
		IsLeapYear=((n Mod 4=0) And (n Mod 100 <>0)) Or (n Mod 400=0) 		
	End Function

See Also:

mmbasic/isleapyear_function_to_determine_if_the_given_year_is_a_leap_year_on_the_gregorian_western_calendar.txt · Last modified: 2024/01/19 09:30 by