## ramdom RND

Here we can discuss about the problem found
Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

### ramdom RND

Cicciocb, It seems that "rdn (number)" returns only values between 0 and number-1, not between 0 and number:

Code: [Local Link Removed for Guests]

``````DIM frecuency(7)
timer0 100, random
wait

random:
r = rnd(7) ' Returns a random number in the range from 0 to 7
frecuency(r) = frecuency(r) + 1
iteration = iteration + 1
if iteration = 100 then
for i = 0 to 7
result\$ = result\$ + str\$(frecuency(i)) + " "
next i
wlog result\$
iteration = 0
result\$ = ""
end if
return
``````
cicciocb
Posts: 413
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 92 times
Been thanked: 297 times
Contact:

### Re: ramdom RND

HI Fernando,
this is normal as the final value is not inclusive.
So RND(5) gives values from 0 to 4 (range of 5).

This is as the visual basic rnd() function that returns a value less than 1 but greater than or equal to zero.

Some references

Fernando Perez
Posts: 118
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 62 times
Been thanked: 67 times

### Re: ramdom RND

You're right, it's something I didn't remember.
But it is that in the help of Annex she says:
image.png
And it can confuse language novices (or not so novices).
Notice that the link you put in the first place says textually:
"expression evaluates to the total number of integers, including 0, from which the random number can be selected. That is, if n is the value of expression, the random number is generated from the numbers 0 through (n - 1)."
I think this should be clarified in the Annex help.
It has nothing to do with the subject, but for those interested in BASIC Archeology, I have found this:
You do not have the required permissions to view the files attached to this post.
cicciocb