Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Feb 2003 12:54:58 -0800
From:      Bakul Shah <bakul@bitblocks.com>
To:        Mark Murray <mark@grondar.org>
Cc:        current@FreeBSD.ORG
Subject:   Re: rand() is broken 
Message-ID:  <200302022054.PAA23917@tonnant.cnchost.com>
In-Reply-To: Your message of "Sun, 02 Feb 2003 20:15:05 GMT." <200302022015.h12KF5aX050851@grimreaper.grondar.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Would you prefer that we defined random() as
> 
> int
> random(void)
> {
> 	static int retval = 0;
> 
> 	return retval++;
> }

No because that would be a change from the exisiting random()
behavior :-)

As I indicated in my earlier email random() is not broken,
srand() is (as corrected by Andrey Chernov) so you won't be
fixing any bugs by changing random().  If you guys had left
the original rand() alone we wouldn't be discussing any of
this....

random(3) also provides an initstate() call which presumably
allows you to change the amount of randomnes.  So here is
another suggestion: why not fold your algorithm change in
that function?  For example,

    initstate(seed, "RC4", 3);

changes the algorithm to RC4.  Yes, this is a change in the
interface but one I am sure most people can live with.

> > There is an expectation that on subsequent releases of the
> > same OS things continue to work.
> 
> Where is that expectation guaranteed?
> Where is that expectation supported?

This expectation is a reasonable one.  Most commerical OSes
do a good job of maintaining compatibility.  IRIX certainly
did a pretty good job of it.  FreeBSD also does a pretty good
job on the whole.

> The two are related topics.

Yes, but not the same.

> Consider the (joking reference to) "elephant-free biology". :-)

The way things are going we will be there pretty soon :-(

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?200302022054.PAA23917>