Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 02 Feb 2003 16:37:07 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        Bakul Shah <bakul@bitblocks.com>, Mark Murray <mark@grondar.org>, current@FreeBSD.ORG
Subject:   Re: rand() is broken
Message-ID:  <3E3DB9B3.A233B848@mindspring.com>
References:  <200302022106.h12L6naX051530@grimreaper.grondar.org> <200302022159.QAA13933@wellington.cnchost.com> <20030202223725.GA72744@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
Steve Kargl wrote:
> 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


386BSD 0.1+
patchkit	TRU64

660787754	660787754    
327548691	327548691
2009993994	2009993994
1653966416	1653966416
1074113008	1074113008
2142626740	2142626740
1517775852	1517775852
1453318125	1453318125
619607807	619607807
199986393	199986393

I can fire up my HP/UX and SunOS 4.1.3-U1 boxes too, if you need
those, but I'm pretty sure the reason you got a different answer
for newer Solaris was because it uses the SVR4 code, instead.

The *48() functions are also identical (linear congruential); I
used to use them for physics simulations.  The f2c compiler did
not have the functions until I personally added them to the
library.

-- Terry

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?3E3DB9B3.A233B848>