Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Because random returns a double, I think it is very possible that we
> > could return 1 due to rounding,
>
> Not unless your machine has a "double" type with less than 32 bits of
> precision, which seems pretty unlikely. It'd be sufficient to do
>
> /* result 0.0 <= x < 1.0 */
> result = ((double) random()) / ((double) MAX_RANDOM_VALUE + 1.0);
Here is a patch that makes this change, and cleans up other
MAX_RANDOM_VALUE uses.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
In response to
pgsql-hackers by date
| Next: | From: Alvaro Herrera | Date: 2006-02-01 17:29:05 |
| Subject: Re: [HACKERS] autovacuum |
| Previous: | From: Chris Browne | Date: 2006-02-01 17:14:41 |
| Subject: Re: autovacuum |
pgsql-patches by date
| Next: | From: Bruce Momjian | Date: 2006-02-01 17:45:11 |
| Subject: Re: TODO-Item: B-tree fillfactor control |
| Previous: | From: Bruce Momjian | Date: 2006-02-01 15:24:11 |
| Subject: test, please ignore |