Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2001 21:18:04 -0600
From:      "Jacques A. Vidrine" <n@nectar.com>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        Kris Kennaway <kris@FreeBSD.ORG>, arch@FreeBSD.ORG
Subject:   rand(3) (was Re: cvs commit: ports/astro/xglobe/files patch-random)
Message-ID:  <20010226211804.A44846@spawn.nectar.com>
In-Reply-To: <200102270310.UAA09594@usr05.primenet.com>; from tlambert@primenet.com on Tue, Feb 27, 2001 at 03:10:31AM %2B0000
References:  <20010226090108.C42108@spawn.nectar.com> <200102270310.UAA09594@usr05.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 27, 2001 at 03:10:31AM +0000, Terry Lambert wrote:
> > > So if I run the same program, compiled on a Solaris box, and
> > > compiled on a FreeBSD box, both linked against the platform
> > > libc, I will get the same results from both machines, without
> > > having to carry the random number generator code with my
> > > program, over to the new platform?
> > 
> > Why do you expect this anyway?
> 
> I am a scientist.  Repeatability of experiments is important.

I meant:  Why do you expect that, for example, Solaris's rand()
implementation would give the same results as FreeBSD's rand()
implementation, or that on any other platform?  The algorithm
is not specified by ISO C, nor by POSIX, nor by SUSv2.  In fact,
the latter goes so far as to add:

     The following code defines a pair of functions which could be incorporated
     into applications wishing to ensure that the same sequence of numbers is
     generated across different machines: 


     static unsigned long int next = 1;
     int myrand(void) { ... a random number generator ... }

The implication being, of course, that if you want your results to be the same
across platforms, than you need to provide your own PRNG instead of using
rand().

Cheers,
-- 
Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010226211804.A44846>