Re: Way for computing random primes in standard C.
- From: David Holland <dholland@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Mar 2006 00:41:49 +0000 (UTC)
On 2006-02-28, Ben Bacarisse <ben.usenet@xxxxxxxxx> wrote:
On Mon, 27 Feb 2006 21:19:19 -0800, websnarf wrote:
As one final comment -- using the ANSI C's rand() is bad because the
state size is so small
I don't think the standard mandates any state size, does it? I don't
think there is nothing to stop rand() being a very high quality generator.
Historically, srand() returned the state of the generator in an
unsigned int, and allowed you to restart or resume sequences by
passing that value back to srand(). This is obviously incompatible
with a high-quality implementation, which is why the BSD world got
random() and srandom().
Said usage of rand() seems to be thoroughly deprecated and nearly
forgotten nowadays, although traces can still be found. Feeding
"return the old seed" to Google yields quite a few variants of the old
BSD random(3) man page's discussion of the issue.
Nonetheless, on a lot of platforms rand() still gets you a low-quality
generator. Always check the documentation...
--
- David A. Holland
(the above address works if unscrambled but isn't checked often)
.
- Prev by Date: Re: Implementation of functions in math.h on clc-wiki
- Next by Date: Re: Implementation of functions in math.h on clc-wiki
- Previous by thread: Re: Way for computing random primes in standard C.
- Next by thread: Re: Help in c pointers
- Index(es):
Relevant Pages
|