Home > Archive > FoxPro database connector > April 2005 > How to create a random number generator









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to create a random number generator
xmail123@yahoo.com

2005-04-07, 8:05 pm


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-04-07, 8:05 pm

Hi,
You may want to have a look at the RAND() function.
hth
Mark

"xmail123@yahoo.com" wrote:

>
> 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-04-07, 8:05 pm

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

<xmail123@yahoo.com> wrote in message =
news:424a2123.690312727@127.0.0.1...
>=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
>

xmail123@yahoo.com

2005-04-07, 8:05 pm

On Wed, 30 Mar 2005 11:03:31 -0500, "Rick Bean"
< rgbean@unrealmelange
-inc.com> wrote:
[color=darkred]
>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
>
><xmail123@yahoo.com> wrote in message =
>news:424a2123.690312727@127.0.0.1...

xmail123@yahoo.com

2005-04-07, 8:05 pm

Thank you very much. Problem solved. :)


On Wed, 30 Mar 2005 11:03:31 -0500, "Rick Bean"
< rgbean@unrealmelange
-inc.com> wrote:
[color=darkred]
>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
>
><xmail123@yahoo.com> wrote in message =
>news:424a2123.690312727@127.0.0.1...

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com