Trying to generate random random numbers!

Peter Lamb prl at iti.org
Mon Mar 18 21:42:28 AEST 1991


jik at athena.mit.edu (Jonathan I. Kamens) writes:

>In article <7161 at bgsuvax.UUCP>, sapienza at 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 at iis.ethz.ch	Tel:   +411 256 5241
Integrated Systems Laboratory
ETH-Zentrum, 8092 Zurich



More information about the Comp.unix.programmer mailing list