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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

recognising an integer

Status
Not open for further replies.

q1120537

Technical User
Dec 22, 2003
1
AU
I wish Qbasic to recognise an integer. I need it to distinguish a leap year, ie IF year No. / 4 = integer THEN execute leap year statements.
i cant seem to find a way to do this.
 
if i mod 4 = 0 then

(x mod y returns remainder of x/y, so it would be 0 if x/y is integer)
 
That is the BEST way (using MOD)...

The second best way is to check the number against an integer of itself...

Code:
If X = Int(X) then
  'X is an integer
Else
  'X is Not an integer
End if

Just in case a situation rises where you can't or don't want to use MOD ;-)

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top