home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / programm / 2610 < prev    next >
Encoding:
Text File  |  1992-09-15  |  844 b   |  18 lines

  1. Newsgroups: comp.programming
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!Urmel.Informatik.RWTH-Aachen.DE!messua!dak
  3. From: dak@messua.informatik.rwth-aachen.de (David Kastrup)
  4. Subject: rand() quality. Was: Re: FULL HOUSE (SOLUTION)
  5. Message-ID: <dak.716561621@messua>
  6. Sender: news@Urmel.Informatik.RWTH-Aachen.DE (Newsfiles Owner)
  7. Nntp-Posting-Host: messua
  8. Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
  9. References: <1992Sep13.223147.28768@wuecl.wustl.edu> <1992Sep14.184939.10440@austin.eds.com>
  10. Date: 15 Sep 92 12:53:41 GMT
  11. Lines: 5
  12.  
  13.  
  14. rand() is maybe not that bad. It only gets misused too often. Using it
  15. by modulo is the wrong attitude, because the value is distributed more
  16. or less evenly, not the bits (the less bits you extract, the worse you get).
  17. Use rand/(MAXUNSIGNED/52 + 1) instead of rand%52.
  18.