Rnd() ignores the maximum value

Mistrel

Member
If you run this example you'll see that rnd() never returns 1.

Sub App_Start
x=0
Do
n=Rnd(0,1)
If n=0 Then
Msgbox(n)
Else
Msgbox(n)
End If
Loop Until x=1
End Sub
 

Mistrel

Member
Sorry. I admit that I skimmed over the documentation for rnd() (as short as it was). I've never seen a rnd function that ignores the upper limit before and assumed wrong. I was convinced this was a bug.

:sign0013:
 

Cableguy

Expert
Licensed User
Longtime User
In the old days, in my zx spectrum ++, rnd only returned a value between 0 and....1, except for the ....1 so we ould get decimal of 0.1,0.2,....etc and we couldnt even state the max or min values.... now that was confusing....:signOops:
 
Last edited:

specci48

Well-Known Member
Licensed User
Longtime User
In the old days, in my zx spectrum ++, rnd only returned a value between 0 and....1, except for the ....1 so we ould get decimal of 0.1,0.2,....etc and we couldnt even state the max or min values.... now that was confusing....:signOops:

... max values were possible ...

10 LET A = INT(RND*N)

... results for A are values from 0 to N-1 ... :)

specci48
 
Top