Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Feb 2003 20:56:25 +0200 (EET)
From:      Narvi <narvi@haldjas.folklore.ee>
To:        phk@FreeBSD.ORG
Cc:        "Andrey A. Chernov" <ache@nagual.pp.ru>, Mark Murray <mark@grondar.org>, Doug Barton <DougB@FreeBSD.ORG>, Kris Kennaway <kris@obsecurity.org>, <current@FreeBSD.ORG>
Subject:   Re: rand() is broken 
Message-ID:  <20030205205444.S43637-100000@haldjas.folklore.ee>
In-Reply-To: <31532.1044211424@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

On Sun, 2 Feb 2003 phk@FreeBSD.ORG wrote:

> In message <20030202183826.GA66487@nagual.pp.ru>, "Andrey A. Chernov" writes:
> >On Sun, Feb 02, 2003 at 19:32:50 +0100, phk@freebsd.org wrote:
> >>
> >> Anyway, last time we discussed this, I think we stuck with the rand()
> >> we had because we feared that people were using it's repeatable well
> >> documented sequence of random numbers in regression testing.
> >
> >As documented, it must be repeatable across the calls for same seed, that
> >is all. It not means repeatable accross platforms or across different OS
> >versions. In fact it is already not repeatable across different OS'es, so
> >regression is limited. Also, regression must not stop bugs fixing progress
> >in anycase.
>
> Our manual pages do not comprehensively list all compatibility
> concerns or concessions, waving our manpage about does not address
> the concern.
>
> As I said, I don't know how big a concern this is.  But last time
> it was enough of a concern to make us keep rand() as it was.
>

man srand on another system (for what its worth) says:

     The  rand()  function  uses  a  multiplicative  congruential
     random-number  generator with period 2**32 that returns suc-
     cessive pseudo-random numbers in the range of 0 to  RAND_MAX
     (defined in <stdlib.h>).

     The  srand() function uses the argument seed as a seed for a
     new sequence of pseudo-random numbers to be returned by sub-
     sequent calls to rand(). If srand() is then called with  the
     same  seed value, the sequence of pseudo-random numbers will
     be repeated.  If  rand()  is  called  before  any  calls  to
     srand()  have been made, the same sequence will be generated
     as when srand() is first called with a seed value of 1.


> Please surf the mail-archives to find the discussion, it contained
> a lot of good arguments from both sides, arguments which should
> be thought about before changing rand().
>
> --
> Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
> phk@FreeBSD.ORG         | TCP/IP since RFC 956
> FreeBSD committer       | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-current" in the body of the message
>


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?20030205205444.S43637-100000>