|
-
May 17th, 2001, 05:38 AM
#1
Thread Starter
Registered User
Completely random?
Ok now I need to generate a really large random number, between 9000000000000000000 and 9999999999999999999. Now the rnd function on its own doesn't generate a small enough number to be useful in the situation. I multiplied three rnd number together to get an extremely tiny number.
The question:
Have I introduced any bias?
Here is the function:
MsgBox Len(Random("9000000000000000000", "9999999999999999999"))
Private Function Random(ByVal Min$, ByVal Max$) As Variant
Dim x, y, z
Randomize
x = CDec(Min): y = CDec(Max): z = CDec(Rnd) * CDec(Rnd) * CDec(Rnd)
Random = CDec(((y - x + 1) * z + x))
If InStr(1, Random, ".") Then Random = Left$(Random, InStr(1, Random, ".") - 1)
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|