Date: Sun, 2 Feb 2003 14:37:25 -0800 From: Steve Kargl <sgk@troutmask.apl.washington.edu> To: Bakul Shah <bakul@bitblocks.com> Cc: Mark Murray <mark@grondar.org>, current@FreeBSD.ORG Subject: Re: rand() is broken Message-ID: <20030202223725.GA72744@troutmask.apl.washington.edu> In-Reply-To: <200302022159.QAA13933@wellington.cnchost.com> References: <200302022106.h12L6naX051530@grimreaper.grondar.org> <200302022159.QAA13933@wellington.cnchost.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Feb 02, 2003 at 01:59:25PM -0800, Bakul Shah wrote:
>
> AFAIK all random(3) implementations in various versions of
> Unix come from Earl's original 4.2BSD implementation so in my
> view the _expected_ behavior is to see the _exact_ same
> sequence starting from a given seed. This function is called
> "random()" but it is equivalent to a mathematical function
> which must provide the same sequence for the exact same
> input.
>
I was going to stay out of this, but
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
long x;
x = 100L;
srandom(x);
for (i = 0; i < 1010; i++) {
x = random();
printf("%ld\n", x);
}
return 0;
}
Last 10 digits.
FreeBSD Redhat SunOS
660787754 660787754 645318364
327548691 327548691 1583150371
2009993994 2009993994 715222008
1653966416 1653966416 1349166998
1074113008 1074113008 566227131
2142626740 2142626740 1382825076
1517775852 1517775852 583981903
1453318125 1453318125 1453942393
619607807 619607807 1952958724
199986393 199986393 1599163286
--
Steve
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?20030202223725.GA72744>
