Bruce Momjian <pgman@candle.pha.pa.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 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match