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