File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.75 2007/12/11 02:31:49 tgl Exp $
2+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.76 2008/03/10 01:23:04 tgl Exp $
33 *
44 * pgbench: a simple benchmark program for PostgreSQL
55 * written by Tatsuo Ishii
@@ -191,11 +191,15 @@ usage(void)
191191 fprintf (stderr , "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor] [-F fillfactor] [-U login][-d][dbname]\n" );
192192}
193193
194- /* random number generator */
194+ /* random number generator: uniform distribution from min to max inclusive */
195195static int
196196getrand (int min , int max )
197197{
198- return min + (int ) (((max - min ) * (double ) random ()) / MAX_RANDOM_VALUE + 0.5 );
198+ /*
199+ * Odd coding is so that min and max have approximately the same chance of
200+ * being selected as do numbers between them.
201+ */
202+ return min + (int ) (((max - min + 1 ) * (double ) random ()) / (MAX_RANDOM_VALUE + 1.0 ));
199203}
200204
201205/* call PQexec() and exit() on failure */
You can’t perform that action at this time.
0 commit comments