Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Is integer?
- From: john at jwarner.com (John Warner)
- Subject: [Javascript] Is integer?
- Date: Mon May 29 09:32:12 2006
A leap year is any year that can be divided evenly by 4 (year % 4 = 0) but years ending in 00 (2000, 1900, 2100) must (00Year % 400 = 0) so 2000 is a leap year, 2100 is NOT even though it can be divided by 4, but not 400. John Warner > -----Original Message----- > From: javascript-bounces@xxxxxxxxxx > [mailto:javascript-bounces@xxxxxxxxxx] On Behalf Of Allard Schripsema > Sent: Monday, May 29, 2006 9:45 AM > To: [JavaScript List] > Subject: RE: [Javascript] Is integer? > > > Hi > the right word in English is leapyear. > You can use the modulus operator (it shows what's left after > you divide the two values): > > function isLeapYear(year) { > if ((year % 4) == 0) { > return true; > } else{ > return false; > } > } > > Another thing: the rules of a leapyear are a bit more complex > than the simple dividable by 4 as far as i know.... > > Hope this helps, > > allard Schripsema > www.VisualDigital.com.br > > -----Original Message----- > From: javascript-bounces@xxxxxxxxxx > [mailto:javascript-bounces@xxxxxxxxxx]On Behalf Of Peter > Lauri > Sent: Monday, May 29, 2006 5:28 AM > To: javascript@xxxxxxxxxx > Subject: [Javascript] Is integer? > > > Best group member, > > Is there any function that checks if something is an integer? > I did not find one and created this temporary function: > > function isInteger(thenumber) { > thenumberceil = Math.ceil(thenumber); > if(thenumberceil>thenumber) return false; > else return true; > } > > Why I actually need this is because I need to find out if a > year is a "skott year" (do not know the English word, but the > years when February has 29 days instead of 28). Is there any > function for that? I created this temporary > function: > > function isSkottYear(y) { > yeardiv = y/4; > if(isInteger(yeardiv)) return true; > else return false; > } > > There is probably better ways of doing this, are they? > > Best regards, > Peter Lauri > > _______________________________________________ > Javascript mailing list > Javascript@xxxxxxxxxx > https://lists.LaTech.edu/mailman/listinfo/javascript > > > > _______________________________________________ > Javascript mailing list > Javascript@xxxxxxxxxx > https://lists.LaTech.edu/mailman/listinfo/javascript >
- Follow-Ups:
- [Javascript] Is integer?
- From: tedd
- [Javascript] Is integer?
- References:
- [Javascript] Is integer?
- From: Allard Schripsema
- [Javascript] Is integer?
- Prev by Date: [Javascript] Is integer?
- Next by Date: [Javascript] Is integer?
- Previous by thread: [Javascript] Is integer?
- Next by thread: [Javascript] Is integer?
- Index(es):