Newbie Question on integers

Non-platform specific questions.

Newbie Question on integers

Postby Just4Fun » Thu Apr 29, 2004 4:48 pm

When I do this:

int iRandomInteger
iRandomInteger=49
Lotto.textNumber=(rand(iRandomInteger)+1)

I get a random float number (ie 28.549140) instead of an integer result.
What am doing wrong? TIA
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby jazz_e_bob » Thu Apr 29, 2004 6:30 pm

You need to use:

Lotto.textNumber=round((rand(iRandomInteger)+1));

double round(double a)
Round a number to nearest integer.
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Just4Fun » Thu Apr 29, 2004 8:02 pm

jazz-e-bob:
I don't want to "clutter-up" the forum with a lot of non-technical items so I won't always tell you how grateful I am for your help. Still, I do like to let you know it now and again. Thank you. :lol:
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby jazz_e_bob » Thu Apr 29, 2004 8:19 pm

understood :)

over and out :wink:
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest