random without decimal

Game Editor comments and discussion.

random without decimal

Postby futuro » Fri May 15, 2009 3:29 pm

you know if one random haven't decimal?

I need one number of 12 posible, but random..

help :? :? :? :?
alguien que hable mi idioma ÑñÑñÑñ
User avatar
futuro
 
Posts: 37
Joined: Mon Apr 13, 2009 1:22 pm
Score: 0 Give a positive score

Re: random without decimal

Postby jimmynewguy » Fri May 15, 2009 8:50 pm

if it's an integer(int) it won't have numbers, so you can do this 2 ways

Code: Select all
int j;
j = rand(12);//for textNumber just have it = j and it won't have a decimal


~~~OR~~~

Code: Select all
variable = round(rand(12);
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: random without decimal

Postby Hblade » Fri May 15, 2009 9:26 pm

Or you could make the int a float variables instead of int. Float can never have decimals. To do this, get the name of your current variable, delete it. In Global Code, type float variable. Replace variable with the name of your variable.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: random without decimal

Postby pyrometal » Sat May 16, 2009 2:45 am

False! A float IS a real number (float as in "floating point"). A double is also decimal number but can contain larger numbers with higher precision in the decimals, (double stands for "double precision"). The use of an integer in this case is appropriate. Sorry for the contradiction Hblade...
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: random without decimal

Postby futuro » Sat May 16, 2009 7:45 am

the problem is that GE not use
Code: Select all
byte
whith eigth posibilitys I can work also



jimmynewguy = jimmynewpoint
thanks
alguien que hable mi idioma ÑñÑñÑñ
User avatar
futuro
 
Posts: 37
Joined: Mon Apr 13, 2009 1:22 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron