From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: random() returns predictable values Date: Thu, 27 Nov 1997 18:51:06 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 31 Message-ID: <347DC11A.408D@cs.com> References: <347C970A DOT 3D0E AT swipnet DOT se> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp244.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Deltaman wrote: > > Are there any good random routines to substitute random()? > It returns too predictable values to be of real value to me. Even with a > random seed it still returns the same values several times in a row. > Does anyone know of a way to get more random numbers? This is the first time anybody has reported any such problem with random(). Are you sure you are seeding it? The clock value is a good seed to use: #include #include srandom( (int) time( NULL ) ); ... x = random() % 100; Also remember, you only need to use srandom() once. If this doesn't help, please post some more details, like some sample program code that generates non-random numbers. The period of random() is supposed to be at least 2^32. -- --------------------------------------------------------------------- | John M. Aldrich | "A woman is not property, and hus- | | aka Fighteer I | bands who think otherwise are living | | mailto:fighteer AT cs DOT com | in a dreamworld." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------