Page 2 of 2

Re: Get a random between 2 numbers

PostPosted: Sat Jul 10, 2010 5:57 pm
by Bee-Ant
@lcl:
Bee-Ant wrote:
Code: Select all
float GetRandomBetween(float ii,float jj)
{
    float ij=rand(max(ii,jj)-min(ii,jj));
    return ij+min(ii,jj);
}


With this code, you can return any number between any number.
If you want to return a number between negative with positive then just type:
Code: Select all
textNumber=GetRandomBetween(-5,5); //or
textNumber=GetRandomBetween(5,-5);

Please try first before you ask :D

Re: Get a random between 2 numbers

PostPosted: Sat Jul 10, 2010 5:59 pm
by Hblade
Yeah :3

Re: Get a random between 2 numbers

PostPosted: Sat Jul 10, 2010 10:31 pm
by lcl
Oh... :oops: sorry.
Good work! :D I didn't understand nearly anything about your code... :shock:

Re: Get a random between 2 numbers

PostPosted: Fri Aug 13, 2010 6:25 am
by Scorpion50o1
hey could we make a little dice rolling game or quarter flipping thing outta this?

Re: Get a random between 2 numbers

PostPosted: Tue Sep 28, 2010 10:51 pm
by TSO
I can't seem to get any of these to work and all I need is a random number of 1 or 2 in a variable I can check.