home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / c / 13251 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.4 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. From: gt@rundart.demon.co.uk (Giles Todd)
  3. Path: sparky!uunet!pipex!demon!rundart.demon.co.uk!gt
  4. Subject: Initializing Random Seeds 
  5. Distribution: world
  6. References: <1992Sep4.173259.12437@maccs.dcss.mcmaster.ca>
  7. Organization: Rundart Limited
  8. Lines: 24
  9. Date: Sat, 5 Sep 1992 01:56:07 +0000
  10. Message-ID: <715658917snx@rundart.demon.co.uk>
  11. Sender: usenet@gate.demon.co.uk
  12.  
  13.  
  14. In article <1992Sep4.173259.12437@maccs.dcss.mcmaster.ca> rickan@maccs.dcss.mcmaster.ca writes:
  15.  
  16. >Please excuse me if this is a FAQ, but is there a ANSI-compliant means
  17. >of initializing a random seed which has a reasonably low probability
  18. >of recurring? At the moment, I'm using srand in conjunction with
  19. >time(&t). Unfortunately, on a fast machine, the time delay is often
  20. >< 1 second, resulting in the production of the same random value.
  21. >
  22. >I've avoided this problem by use of a time delay, but I'm convinced
  23. >that there must be a more elegant and efficient means of doing this.
  24. >
  25. >Any suggestions would be appreciated,
  26.  
  27. Ideally, you want some sort of non-deterministic event.  I have often
  28. arranged things so that the seed comes from timing the interval between
  29. two user supplied keystrokes (preferably with a timer resolution of much
  30. less than 1 second).
  31.  
  32. Giles.
  33. -- 
  34. Giles Todd                      gt@rundart.demon.co.uk (Internet)
  35. Voice: +44 925 33472            Data: +44 925 414696
  36. Rundart Ltd, 5 Brentnall Close, Great Sankey, Warrington, WA5 1XN, UK
  37.