Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/02/02 06:58
Read: times


 
#25119 - RE: Random number between two given numbers
If you have a C function that returns a random number between 0 and some max limit, say like:

n = rand(int max);

A function that accepts a minimum and a maximum limit would simply be:
n = random(min, max);
where....

int random(int min, int max)
{
return (min + rand(max));
}

easy :-))
Of course, it will work even if you write your own pseudo-random rand(max) function.
BTW I hope this is somehow related to 8051, coz else I just replied to an off-topic post!!

Kundi

List of 3 messages in thread
TopicAuthorDate
Random number between two given numbers            01/01/70 00:00      
RE: Random number between two given numbers            01/01/70 00:00      
RE: Random number...oops            01/01/70 00:00      

Back to Subject List