|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 1475 |
Random Numbers |
05/11/2006 @ 20:15 by 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
Answer n° 1 -------- 05/11/2006 @ 20:54 by aldweb
visitor |
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
Answer n° 2 -------- 05/11/2006 @ 21:20 by Garfield
visitor |
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?
|
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|