programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Paul Clapham
• Ron McLeod
• Jeanne Boyarsky
• Tim Cooke
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Henry Wong
Saloon Keepers:
• Tim Moores
• Tim Holloway
• Stephan van Hulst
• Carey Brown
• Frits Walraven
Bartenders:
• Piet Souris
• Himai Minh

# LeapYear

Ranch Hand
Posts: 1249
• Number of slices to send:
Optional 'thank-you' note:
I have seen recently code of GregorianCalendar in which I saw the function of isLeapYear:

That was as follows:

Now I really cann't relate why there is a reason to check whether is it divisible by 100 and 400 after checking divisible by 4.... I mean to say that if a number is divisible by 4 then it will be automatically divisible by 100 and 400.....

Then what is the use.......

COuld anybody explain this one...

I also don't understand why the code is checking that passed parameter is whether greater then 1582 or not.....

Ranch Hand
Posts: 2412
• Number of slices to send:
Optional 'thank-you' note:
http://www.timeanddate.com/date/leapyear.html

Rancher
Posts: 43027
76
• Number of slices to send:
Optional 'thank-you' note:

I mean to say that if a number is divisible by 4 then it will be automatically divisible by 100 and 400.

So 8 is divisible by 100?

As to 1582, the Gregorian Calendar did not exist before (and there is a 10-day leap in that year).
[ May 03, 2006: Message edited by: Ulf Dittmer ]

Shaan Shar
Ranch Hand
Posts: 1249
• Number of slices to send:
Optional 'thank-you' note:
Oh sorry folks:

I thought it in other way...

...

Well nyways
sorry for this silly question.....

 World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional. Free, earth friendly heat - from the CodeRanch trailboss https://www.kickstarter.com/projects/paulwheaton/free-heat