|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Sujet n° 1475 |
Random Numbers |
le 05/11/2006 @ 20:15 par Garfield
|
Hi
According to the manual, the function RND(v|n) returns an integer pseudo-random number in the [0...v|n] range.
However, from the code I am producing, the [0...v|n] range includes the zero, but does not include v|n itself.
For example, I have been producing the results of RND(9) and I have seen the numbers 0 to 8, but not 9.
Is this correct? Does the RND(v|n) function really produce numbers between 0 and v|n-1 or am I missing something?
Thanks.
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 1 -------- le 05/11/2006 @ 20:54 par aldweb
visiteur |
Hello Garfield,
The documentation says that the RND functions returns an integer pseudo-random number in the [0..v|n[ range, not in the [0..v|n] range.
[0..v|n[ is equivalent to [0..(v|n)-1] range if you want.
So, RND(0) will return values between 0 and 8, never 9.
Cheers, aldweb
@+ aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Réponse n° 2 -------- le 05/11/2006 @ 21:20 par Garfield
visiteur |
Aaaaahhh! Yep, you're right.
I hadn't noticed the reversed bracket. I'll have to revise my HTML/iSilo documentation as well as I've typed it wrong in there too!
However, if it's OK with you, I prefer to state that it's in the range [0...v|n-1]. I feel this is clearer. A reversed bracket is very easy to miss (I missed it!).
What do you think?
|
|
|
sujet actif
sujet clos
Important!
Nouveau message -
Rectifier message
Clôturer sujet
Remonter
|
|