Path: utzoo!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!mcsun!cernvax!chx400!chx400!bernina!prl From: prl@iti.org (Peter Lamb) Newsgroups: comp.unix.programmer Subject: Re: Trying to generate random random numbers! Message-ID: Date: 18 Mar 91 11:42:28 GMT References: <7161@bgsuvax.UUCP> <1991Mar18.054012.24970@athena.mit.edu> Sender: news@bernina.ethz.ch (USENET News System) Organization: Swiss Federal Institute of Technology (ETH), Zurich, CH Lines: 31 Nntp-Posting-Host: etzj-gw jik@athena.mit.edu (Jonathan I. Kamens) writes: >In article <7161@bgsuvax.UUCP>, sapienza@bgsuvax.UUCP (Michael A. Sapienza) writes: >|> I could use some help in generating random numbers. The problem I am having >|> is that I get the same set of numbers each time that I run the program. I >|> have tried using srandom (seed) and entering the seed from the keyboard, >|> but this also returns the same random number. Any help would be greatly >|> appreciated! > I have no problem at all using srandom() and random() to get random numbers, >and I expect most of the other readers of this newsgroup have no problem >either, so it's really impossible for us to diagnose the problem you are >having unless you tell us more specifically exactly what your code is doing. >For example, it would help if you would provide a short test program that >doesn't work (i.e. gets the same random numbers each time) for you. There was a bug in (s?)random() in Ultrix 2.0 and 2.2, where srandom calls with the same seed did not generate repeatable sequences. This seems to be fixed in Ultrix 4.0, at least the RISC version. The response from DEC at the time was that it should be fixed in 3.0. For Michael, you should specify at least the OS version and hardware you are having problems with for queries like this. A small code example as Jonathan suggests also makes it easier for people to help you. -- Peter Lamb uucp: uunet!mcsun!ethz!prl eunet: prl@iis.ethz.ch Tel: +411 256 5241 Integrated Systems Laboratory ETH-Zentrum, 8092 Zurich