home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 3545 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  40 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: news.ridgecrest.ca.us!usenet
  3. From: mojaveg@ridgecrest.ca.us (Everett M. Greene)
  4. Subject: Re: Random Number Generation
  5. X-Nntp-Posting-Host: annex045
  6. Content-Type: text/plain; charset=iso-8859-1
  7. Message-ID: <19960220.7D62838.7EC3@mojaveg.ridgecrest.ca.us>
  8. Sender: usenet@ridgecrest.ca.us (Ridgenet Usenet admin)
  9. Content-Transfer-Encoding: 8bit
  10. Organization: none that you'd notice
  11. X-Newssoftware: GRn 2.1 Feb 19, 1994
  12. 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>
  13. Mime-Version: 1.0
  14. Date: Tue, 20 Feb 1996 16:22:46 GMT
  15.  
  16. In article <4g2bi9$1fls@rs18.hrz.th-darmstadt.de> kraemer@clri6f.gsi.de (Michael Kraemer) writes:
  17. > In article <692.6619T1254T1752@in.net>, mave@in.net (John J. Maver, Jr.) writes:
  18. > > 
  19. > >         I want to generate a randum number, like BASIC allowed you to do, in
  20. > > C.  I want a function that I can call with the High and Low numbers and then
  21. > > have it return a number between them.
  22. > > 
  23. > > What I have so far is:
  24. [snip]
  25. > >         It doesn't quite work.  Any hints?
  26. > Why not sth like that:
  27. > #include <stdlib.h>
  28. > ....
  29. >    num = ( (float) rand() / 32767E0 ) * ( high - low ) + low; 
  30.  
  31. In theory, this is a very good suggestion.  In practice, rand() is a
  32. very poor RNG.  Run any common statistical tests on rand()'s output
  33. to see.
  34.  
  35.     -----------------------------------------------------------------------
  36.     Everett M. Greene   (The Mojave Greene, crotalus scutulatus scutulatus)
  37.     Ridgecrest, Ca. 93555           Path: mojaveg@ridgecrest.ca.us
  38.