Sep 26, 2007 #1 ranjit Technical User Apr 14, 2000 131 GB Is it possible to do a calculation and check if the result is a whole number? For example: (a) 2004/4 = 501 (b) 2007/4 = 501.75 I'd like to do the above division and do something in the case of (a) and something else in the case of (b). Any ideas please?
Is it possible to do a calculation and check if the result is a whole number? For example: (a) 2004/4 = 501 (b) 2007/4 = 501.75 I'd like to do the above division and do something in the case of (a) and something else in the case of (b). Any ideas please?
Sep 26, 2007 #2 p5wizard IS-IT--Management Apr 18, 2005 3,165 BE use remainder operator % if ((year % 4) == 0) print "may be leapyear" else print "not leapyear" HTH, p5wizard Upvote 0 Downvote
use remainder operator % if ((year % 4) == 0) print "may be leapyear" else print "not leapyear" HTH, p5wizard
Sep 26, 2007 #3 feherke Programmer Aug 5, 2002 9,540 RO Hi Like p5wizard wrote. Or you can use [tt]int()[/tt] : Code: if (year/4==int(year/4)) print "may be leapyear" else print "not leapyear" Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Like p5wizard wrote. Or you can use [tt]int()[/tt] : Code: if (year/4==int(year/4)) print "may be leapyear" else print "not leapyear" Feherke. http://rootshell.be/~feherke/
Sep 26, 2007 Thread starter #4 ranjit Technical User Apr 14, 2000 131 GB Many thanks guys Upvote 0 Downvote