This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

random/srandom (was Re: link problems)


>>>>> "GN" == Geoffrey Noer <noer@cygnus.com> writes:

 GN> James Paul Morgan wrote:
 >>  As far as I can tell, the gnu-win32 does not have the random and
 >> srandom functions.  It only has the rand and srand functions,
 >> which are not nearly as random.  I have had problems with moving
 >> software from an AIX system to my Win95 system becuase of this.
 GN> [...]

 GN> You are correct.  We have not implemented these yet as of the
 GN> upcoming beta 18 release.

 GN> If someone can point me to a Berkeley-licensed implementation of
 GN> them or write them and send me a copyright assignment form, I'll
 GN> add them...

I'm currently away from my Win95 laptop, but I just want to point out
that the botched rand function can be identified by looking at the
least significant bit:  It looks random for a good implementation, but
it's a periodic 0-1 sequence for many rand's. On my Linux box at the
office, rand and random are the same function and both are "good."
Maybe the Linux code is a good starting point for inclusion in cygwin.

On a related note, I've given up some time ago relying on system
functions to generate random numbers. I use my own, which I derived
from the algorithms in "Numerical Recipes in C." This is not to say
that cygwin shouldn't provide a decent random/srandom pair. It's just
that if you rely on the random number generator for more than an
extemporary exercise, and you want reproducibility of results, you
should seriously consider using your own random number generator.

Fabio

-- 
Fabio Somenzi          | Phone: 303-492-3466
University of Colorado | Fax:   303-492-2758
ECE Dept.              | Email: Fabio@Colorado.EDU
Boulder CO 80309-0425  | WWW:   http://vlsi.colorado.edu/~fabio
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]