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