PDA

View Full Version : forget how to create random variable


leingod
28/12/2011, 01:58 AM
I forgot how to create random variable

its look like this?
new randomz = random(100 - 10);

The code i want is random from 10 to 100

spedico
28/12/2011, 02:02 AM
#define RandomEx(%0,%1) (random((%1) - (%0)) + (%0))'

RandomEx(10, 100);

leingod
28/12/2011, 02:05 AM
Explain pls :)

Tee
28/12/2011, 02:06 AM
Wrong topic.

leingod
28/12/2011, 02:07 AM
Wrong topic.

pardon me
then where i can post this?

TheArcher
28/12/2011, 02:12 AM
Wrong topic.

It is the right topic.

OnTopic.

spedico used marcros to do a variable fast, easy and usefull.




#define RandomEx(%0,%1) floatround(random((%1) - (%0)) + (%0))



That's more accurate.

Example:

#define RandomEx(%0,%1) floatround(random((%1) - (%0)) + (%0))
new result = RandomEx(10,100);
printf(" result is %d ", result);

Tee
28/12/2011, 02:24 AM
pardon me
then where i can post this?

It is the right topic.

OnTopic.

spedico used marcros to do a variable fast, easy and usefull.




#define RandomEx(%0,%1) floatround(random((%1) - (%0)) + (%0))



That's more accurate.

Example:

#define RandomEx(%0,%1) floatround(random((%1) - (%0)) + (%0))
new result = RandomEx(10,100);
printf(" result is %d ", result);

I didn't say wrong board, I said wrong topic. I meant I posted a reply in the wrong topic...

Deathlane
28/12/2011, 02:42 AM
I prefer you to watch this:
http://www.youtube.com/watch?v=jS7u6r94IFw
I learned it there...

TheArcher
28/12/2011, 01:23 PM
@ObelesMarc

It's more faster using macros than stocks. That makes it more faster.
But stocks can return instead.

Deathlane
14/01/2012, 09:54 AM
Removed