Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Feb 2003 21:49:24 +0100
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Bakul Shah <bakul@bitblocks.com>
Cc:        Edward Brocklesby <ejb@lythe.org.uk>, current@FreeBSD.ORG
Subject:   Re: rand() is broken
Message-ID:  <20030202204924.GA74800@falcon.midgard.homeip.net>
In-Reply-To: <200302022006.PAA25355@valiant.cnchost.com>
References:  <200302021941.h12JfJ1a004169@a.smtp.serv.lythe.org.uk> <200302022006.PAA25355@valiant.cnchost.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.


-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

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




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