home *** CD-ROM | disk | FTP | other *** search
- Path: daily-planet.execpc.com!earth!zieman
- From: zieman@earth.execpc.com (Glenn Zieman)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Random Number Generation
- Date: 21 Feb 1996 03:06:30 GMT
- Organization: Exec-PC BBS - Milwaukee, WI
- Message-ID: <4ge27m$snj@daily-planet.execpc.com>
- References: <199602071623.QAA00075@sable.ox.ac.uk> <Pine.OSF.3.91.960207175121.20357B-100000@hai.hiMolde.no> <19960207.41F660.11A72@aj050.du.pipex.com> <1100.6613T1273T666@himolde.no> <692.6619T1254T1752@in.net> <4g2bi9$1fls@rs18.hrz.th-darmstadt.de> <19
- NNTP-Posting-Host: earth-le1.execpc.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- 960220.7D62838.7EC3@mojaveg.ridgecrest.ca.us>
- Organization: Exec-PC
- Distribution:
-
- Everett M. Greene (mojaveg@ridgecrest.ca.us) wrote:
- : In article <4g2bi9$1fls@rs18.hrz.th-darmstadt.de> kraemer@clri6f.gsi.de (Michael Kraemer) writes:
- : > In article <692.6619T1254T1752@in.net>, mave@in.net (John J. Maver, Jr.) writes:
- : > >
- : > > I want to generate a randum number, like BASIC allowed you to do, in
- : > > C. I want a function that I can call with the High and Low numbers and then
- : > > have it return a number between them.
- : > >
- : > > What I have so far is:
- : [snip]
- : > > It doesn't quite work. Any hints?
- : >
- : > Why not sth like that:
- : >
- : > #include <stdlib.h>
- : > ....
- : > num = ( (float) rand() / 32767E0 ) * ( high - low ) + low;
-
- : In theory, this is a very good suggestion. In practice, rand() is a
- : very poor RNG. Run any common statistical tests on rand()'s output
- : to see.
-
- The way that the orginal posting started by using srand() to the time,
- one when using rand() gets a more random number (at least the random
- numbers don't repeat in the same order each time.)
-
- --
- ___
- / \
- | zieman@execpc.com
- | __ co-syop of EOTU BBS
- | / (414)633-4021
- \__/
- /
- /__
-