home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: news.ridgecrest.ca.us!usenet
- From: mojaveg@ridgecrest.ca.us (Everett M. Greene)
- Subject: Re: Random Number Generation
- X-Nntp-Posting-Host: annex045
- Content-Type: text/plain; charset=iso-8859-1
- Message-ID: <19960220.7D62838.7EC3@mojaveg.ridgecrest.ca.us>
- Sender: usenet@ridgecrest.ca.us (Ridgenet Usenet admin)
- Content-Transfer-Encoding: 8bit
- Organization: none that you'd notice
- X-Newssoftware: GRn 2.1 Feb 19, 1994
- 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>
- Mime-Version: 1.0
- Date: Tue, 20 Feb 1996 16:22:46 GMT
-
- 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.
-
- -----------------------------------------------------------------------
- Everett M. Greene (The Mojave Greene, crotalus scutulatus scutulatus)
- Ridgecrest, Ca. 93555 Path: mojaveg@ridgecrest.ca.us
-