Talk:Leap year
"in the Gregorian calendar"
During 2011 August 13, Markjreed amended the task to specify "in the Gregorian calendar". This contradicted the Ruby example, which already used the Julian calendar for years before 1583. I have now added an alternate Ruby example that uses proleptic Gregorian calendar. --Kernigh 18:52, 6 October 2011 (UTC)
- There used to be a lengthy discussion here about the leap year rules in effect that led to that change. What happened to the history of the talk page? --Markjreed 19:11, 12 March 2012 (UTC)
Faster implementation
After some experiments with gcc, I suggest to write, instead of the usual version :
(Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 16 = 0))
That way there is only one division to do. Even though gcc uses imul to do that, it's still shorter. And probably any compiler will optimize better this code. Okay, it's probably not *that* important to optimize Is_Leap_Year ! Nochnix 11:06, 13 February 2012 (UTC)
REXX Version 4
Actually This seems to be not necessary:
If a year below 100 is to be used, the year should have leading zeroes added (to make it four digits).
Better:
Years with 2 digits are padded with the current century
Years with fewer than 4 digits are padded to the left with zeroes.
<lang rexx>
ok=0
Do y=0 To 999
If leapyear(y)==leapyear(right(y,4,0)) Then ok=ok+1 else Say y leapyear(y) leapyear(right(y,4,0)) End
Say </lang>
shows 1000
Somehow I was mislead:-(
--Walter Pachl 13:37, 17 April 2021 (UTC)