Re: how to generate random number between the range -10 to 10
[email protected] (James Taylor) Thu, 6 Mar 2003 16:58:53 +0000 (GMT)
| Newsgroups | perl.riscos |
|---|---|
| Message-ID | <[email protected]> |
On Thu 06 Mar, Andrew Green wrote: > > In article <[email protected]>, > kenwin charles <[email protected]> wrote: > > > > is it possible you can assist me on how to generate random number > > between the range -10 to 10. > > my $num = int(rand 21) - 10; Yes, but please bear in mind that the RISC OS port of Perl does not produce random numbers uniformly from the rand() function. There is a bug in UnixLib upon which RISC OS Perl is dependent, that causes the random number to be generated incorrectly. There was a thread of discussion about the problem on this very mailing list a while back. See the archives at: http://www.mail-archive.com/riscos%40perl.org/msg00106.html Random number generation is poorly understood by most people and, in that thread, I seem to recall having quite a bit a trouble convincing people to look at the facts. Hopefully, we won't have that problem a second time round. :-) -- James Taylor, Cheltenham, Gloucestershire, UK. PGP key: 3FBE1BF9