1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

Update random() usage so ranges are inclusive/exclusive as required.

This commit is contained in:
Bruce Momjian
2006-02-03 12:45:47 +00:00
parent eb7bd06983
commit 59bb147353
4 changed files with 10 additions and 17 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.119 2005/12/02 02:49:11 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/float.c,v 1.120 2006/02/03 12:45:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -1833,8 +1833,8 @@ drandom(PG_FUNCTION_ARGS)
{
float8 result;
/* result 0.0-1.0 */
result = ((double) random()) / ((double) MAX_RANDOM_VALUE);
/* result [0.0 - 1.0) */
result = (double) random() / ((double) MAX_RANDOM_VALUE + 1);
PG_RETURN_FLOAT8(result);
}