© unknownartist@newsgroup

Every expression in parentheses in the RETURN statement provides a TRUE(1) or FALSE(0). Accordingly the result in total will be TRUE or FALSE.

If the first expression is true, it is a leap year (every 4 years). If the second expressin is true as well, it is not a leap year (exception rule every 100 years). In this case the TRUE of the 100-year-exception-rule would be subtracted from the TRUE of the 4-year-rule and would result in a FALSE ie. no leap year. If the third expression is TRUE as well (exception rule every 400 years - eg. in the year 2000), the no leap year result gets overruled and thus it is leap year again.

This is probably the shortest version of the leap year recognition.

The easiest way to speed up a program is to drop everything you do not need.


/* REXX */
ARG JAHR
RETURN (JAHR // 4 = 0) - (JAHR // 100 = 0) + (JAHR // 400 = 0)
back to Date & Time