home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / programm / 2333 < prev    next >
Encoding:
Text File  |  1992-08-15  |  1.1 KB  |  24 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!wupost!darwin.sura.net!Sirius.dfn.de!Urmel.Informatik.RWTH-Aachen.DE!kaa!dak
  3. From: dak@kaa.informatik.rwth-aachen.de (David Kastrup)
  4. Subject: Re: Any simple Random Number generators?
  5. Message-ID: <dak.713874609@kaa>
  6. Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
  7. Nntp-Posting-Host: kaa
  8. Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
  9. References: <13AUG199218224504@judy.uh.edu> <1992Aug14.104121.29374@corax.udac.uu.se>
  10. Date: 15 Aug 92 10:30:09 GMT
  11. Lines: 11
  12.  
  13. >In article <13AUG199218224504@judy.uh.edu> cscc13@judy.uh.edu (NAVEED IQBAL) writes:
  14.  
  15. >>I want to know how random numbers are generated.
  16. Well, suggesting that you save your last number, in 32bit unsigned systems
  17. you can get good 32-bit numbers by multiplying the last value with 69069
  18. and adding 1. This pretty good, easy to memorize number generator is ana-
  19. lyzed in The Art of Computer programming vol. 2.
  20.  
  21. You have to use the higher bits when wanting a small random number, or the
  22. behaviour will be terrible. That is, use ((long long)rand * 25 >>32) for
  23. a number from 0 to 24.
  24.