pg.ddx.io  pgsql-hackers-win32@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: pgsql-hackers-win32@postgresql.org
Subject: Re: win32 random number generator
Date: Mon, 22 Aug 2005 16:47:46 -0400
Message-ID: <21049.1124743666@sss.pgh.pa.us> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD16D@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3417DD16D@Herge.rcsinc.local>

"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:
> The windows random number of generator (a port of lrand48 in random.c)
> seems a little weak.  It seems to only offer about 16 bits of precision.
> Maybe there is a bug in the implementation?

> esp=# select count(*)  from (select distinct random() from
> generate_series(1,1000000)) q;
>  count
> -------
>  65559
> (1 row)

That's pretty awful, all right.  I get numbers like this on two
different Unix machines:

regression=# select count(*)  from (select distinct random() from generate_series(1,1000000)) q;
 count
--------
 999769
(1 row)

postgres=#  select count(*)  from (select distinct random() from
postgres(# generate_series(1,1000000)) q;
 count
--------
 999787
(1 row)

Anyone care to burrow into the code and see what its problem is?

			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <21049.1124743666@sss.pgh.pa.us>
Permalink:  ../21049.1124743666@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21049.1124743666@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers-win32@postgresql.org
  Cc: tgl@sss.pgh.pa.us, merlin.moncure@rcsonline.com
  Subject: Re: win32 random number generator
  In-Reply-To: <21049.1124743666@sss.pgh.pa.us>
  References: <6EE64EF3AB31D5448D0007DD34EEB3417DD16D@Herge.rcsinc.local> <21049.1124743666@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox