From owner-freebsd-current Sun Feb 2 12:49:30 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 44C3C37B401 for ; Sun, 2 Feb 2003 12:49:29 -0800 (PST) Received: from falcon.midgard.homeip.net (h76n3fls20o913.telia.com [213.67.148.76]) by mx1.FreeBSD.org (Postfix) with SMTP id CFC9E43F85 for ; Sun, 2 Feb 2003 12:49:26 -0800 (PST) (envelope-from ertr1013@student.uu.se) Received: (qmail 80126 invoked by uid 1001); 2 Feb 2003 20:49:25 -0000 Date: Sun, 2 Feb 2003 21:49:24 +0100 From: Erik Trulsson To: Bakul Shah Cc: Edward Brocklesby , current@FreeBSD.ORG Subject: Re: rand() is broken Message-ID: <20030202204924.GA74800@falcon.midgard.homeip.net> Mail-Followup-To: Bakul Shah , Edward Brocklesby , current@FreeBSD.ORG References: <200302021941.h12JfJ1a004169@a.smtp.serv.lythe.org.uk> <200302022006.PAA25355@valiant.cnchost.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200302022006.PAA25355@valiant.cnchost.com> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, Feb 02, 2003 at 12:06:56PM -0800, Bakul Shah wrote: > > Maybe I missed something, but why cannot you just rip random() from libc, > > rename it to bakul_shah_random() and use that in your testing code? Then you > > are safe from any changes to random(), and indeed have a portable RNG if your > > host OS changes. > > Yes, *I* can do it but I don't work at every place they do > simulation! If in the extreme you are suggesting that a > portable application shouldn't rely on any OS features, you > are of course right but that kind of makes mockery of any > claims of compatibility. The point of compatibility is to > not break interfaces unless there is a significant benefit. If your program depends on the exact algorithm used by random() (or rand() for that matter) to not change between OS updates (not to mention between different systems) then that is a bug in your program. The interface will not change just because a different algorithm is used. The exact sequence of random numbers produced is not a part of the interface but rather an implementation detail that portable programs should not depend on. It might also be worth noting that if a good PRNG is needed then one should not use random() or rand() since on some systems their output is not very random. -- Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message