please help me getting infinative value

nam2000ind

New member
Joined
Feb 1, 2007
Messages
2
Programming Experience
Beginner
this is my code and i want to the result of 100000 number..
but after crossing 10000 value i m getting infinativ values....
but in other language like java ...i run the same programme .....it is running perfactly can u guide me where i m doing mistake...rnd() is the random value.....here is the result which i want

0.9997669278359024
1.9879226451633236
0.9931218457149422



Module question1
Sub main()
Dim c AsInteger
Dim RNDNO AsSingle
Dim j, S, T, SX, R, I, SR, SI, X AsDouble

c = 0
SX = 0
SR = 0
SI = 0
For j = 1 To 100000
S = 0
T = 100 - 500 * Math.Log(1 - Rnd())

RNDNO = Math.Log(Rnd())
130: X = -Math.Log(rnd())
c = c + 1
SX = SX + X
S = S + X
If (S < T) ThenGoTo 130
R = S - T
I = X
SR = SR + R
SI = SI + I


Next j
Console.WriteLine(SX / c)
Console.WriteLine(SI / 100000)
Console.WriteLine(SR / 100000)
EndSub
End
Module


 
Back
Top