Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for an integer

Status
Not open for further replies.

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?

 
use remainder operator %

if ((year % 4) == 0) print "may be leapyear"
else print "not leapyear"


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top