Discussion:
How to create a random number generator
(too old to reply)
x***@yahoo.com
2005-03-30 03:45:12 UTC
Permalink
Can any one give me any suggestions on how to create a random number
generator given a seed, max value and min value. I want the return
value to be an integer.

Thanks
Mark
2005-03-30 12:15:01 UTC
Permalink
Hi,
You may want to have a look at the RAND() function.
hth
Mark
Post by x***@yahoo.com
Can any one give me any suggestions on how to create a random number
generator given a seed, max value and min value. I want the return
value to be an integer.
Thanks
Rick Bean
2005-03-30 16:03:31 UTC
Permalink
This is one I've used successfully:

FUNCTION GetRandom
LPARAMETERS pnMin, pnMax
RETURN INT((pnMax - pnMin + 1) * RAND( ) + pnMin)

Note: You should always do a RAND(-1) before you call this routine to intiallize the random seed.

Rick
Post by x***@yahoo.com
Can any one give me any suggestions on how to create a random number
generator given a seed, max value and min value. I want the return
value to be an integer.
Thanks
x***@yahoo.com
2005-03-31 04:46:32 UTC
Permalink
On Wed, 30 Mar 2005 11:03:31 -0500, "Rick Bean"
Post by Rick Bean
FUNCTION GetRandom
LPARAMETERS pnMin, pnMax
RETURN INT((pnMax - pnMin + 1) * RAND( ) + pnMin)
Note: You should always do a RAND(-1) before you call this routine to =
intiallize the random seed.
Rick
Post by x***@yahoo.com
=20
Can any one give me any suggestions on how to create a random number
generator given a seed, max value and min value. I want the return
value to be an integer.
=20
Thanks
x***@yahoo.com
2005-03-31 04:46:59 UTC
Permalink
Thank you very much. Problem solved. :)


On Wed, 30 Mar 2005 11:03:31 -0500, "Rick Bean"
Post by Rick Bean
FUNCTION GetRandom
LPARAMETERS pnMin, pnMax
RETURN INT((pnMax - pnMin + 1) * RAND( ) + pnMin)
Note: You should always do a RAND(-1) before you call this routine to =
intiallize the random seed.
Rick
Post by x***@yahoo.com
=20
Can any one give me any suggestions on how to create a random number
generator given a seed, max value and min value. I want the return
value to be an integer.
=20
Thanks
Loading...