From owner-freebsd-arch Mon Feb 26 20: 0:36 2001 Delivered-To: freebsd-arch@freebsd.org Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (Postfix) with ESMTP id D2DB537B4EC; Mon, 26 Feb 2001 20:00:33 -0800 (PST) (envelope-from tlambert@usr05.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.9.3/8.9.3) id UAA15730; Mon, 26 Feb 2001 20:54:13 -0700 (MST) Received: from usr05.primenet.com(206.165.6.205) via SMTP by smtp02.primenet.com, id smtpdAAATlayOE; Mon Feb 26 20:54:05 2001 Received: (from tlambert@localhost) by usr05.primenet.com (8.8.5/8.8.5) id VAA11366; Mon, 26 Feb 2001 21:00:22 -0700 (MST) From: Terry Lambert Message-Id: <200102270400.VAA11366@usr05.primenet.com> Subject: Re: rand(3) (was Re: cvs commit: ports/astro/xglobe/files patch-random) To: n@nectar.com (Jacques A. Vidrine) Date: Tue, 27 Feb 2001 04:00:22 +0000 (GMT) Cc: tlambert@primenet.com (Terry Lambert), kris@FreeBSD.ORG (Kris Kennaway), arch@FreeBSD.ORG In-Reply-To: <20010226211804.A44846@spawn.nectar.com> from "Jacques A. Vidrine" at Feb 26, 2001 09:18:04 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > 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. [ ... ] > 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(). The 48 bit linear congruential algorithm is a defacto standard for the implementation across UNIX platforms. While the standards do not specify this algorithm, in practice it is there, just as, in practice, select() does not modify the contents of timeval, even though the man page permits it to do so, since code would break. I would be much happier if you were to quote a platform standard instead of a language standard to permit change. Realize that C programs will not necessarily run everywhere without modification, unless they are simple, or unless the author takes great care in crafting the code. Even platform standards have been stretched to, for example, include NT and VMS as "technically POSIX compliant". If you can change the underlying implementation of rand(), you might as well do select() and qsort() (which the manual page acknowledges is modified in an unspecified way), since technically, you would be permitted to do so. The qsort() example is rather quixotic; the select() example, less so, since the change would in fact permit higher resolution in timing than is currently permitted in the context of a select timeout. Can someone put forth a use for rand() which requires this change to permit the use to employe rand() instead of its own code? Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message