Random value

retkehing

Well-known member
Joined
Feb 5, 2006
Messages
153
Programming Experience
Beginner
How to run a randomization which we could get a value like this, 0.000000000013271 Double

Rnd() can only produce random value range from 0.0... until 9.9..., however the chance for getting 0.000000...... value is slim, and moreover now the result I hope is something extremely small. I once thought of using divide the random value but this would cause the different range for randomization. Any technique of increasing the possibility of getting such value without losing the chance of producing 0.0... to 9.9... values? How many 0s (0.0......) after the decimal point, such as could the random function cover?
 
Last edited:
hmm This may or may not help but try using the random class like
VB.NET:
   Dim dblRand As Double
   Dim Rdbl As Random = New Random
   dblRand = Rdbl.NextDouble()

that returns a double between 0 and .9 but you im sure its still unlikely to get 0 often as there are way too many possibilities but maybe playing with that class could give you an idea
 
how about this,

dim number,Odigit,i as integer
dim result as double
dim temp as long=1
dim randomNumber as new random()

number=randomNumber.next(1,13272)
Odigit=randomNumber.next(1,10)

for i=1 to Odigit
temp *=10
next


result=ctype(number/temp,double)

(hope it will help :D ,sorry if i state something wrong)
 
Back
Top