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);
regards, tom lane