You are not likely to come up with a better distribution than the built-in
random generators.  Use the one(s) available to your environment
(VB[Script]: Rnd(), SQL Server: RAND()).

HTH,
Tore.

-----Original Message-----
From: Carlos [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 30, 2002 2:48 PM
To: ActiveServerPages
Subject: Random Numbers


I remember there was conversation about how to generate random numbers
and there being some problems with the functions available (correct me
if I'm wrong).

I've thought about random numbers for a while.  Here's a proposal and I
would like to hear people's feedback.

Time is a great randomizer.  Let's say I need a random number between 1
and 131.  Wouldn't grabbing the current second be a great random number
base?

' Function to generate random number between two numbers
Function RandomNumber (ByVal dblLow, ByVal dblHigh) As Double
  RandomNumber = (DatePart("s", Date()) * (dblHigh - dblLow)) - dblLow
End Function

To call the function.
Dim dblMyNumber
dblMyNumber = RandomNumber(1, 131)

What do you think?  Can we get the millisecond?  As I'm writing this, I
can see that (1) I need to use something smaller than second, otherwise
the numbers won't be that random if random numbers were requested over
and over again and (2) I see that Neil Highley posted about using the
date as a seed.

Any feedback?

Thanks,
Charles Marshall



---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to