From: | Dennis Gearon <gearond(at)cvc(dot)net> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | Peter Choe <choepete(at)mindspring(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: stored procedure |
Date: | 2003-04-01 17:12:24 |
Message-ID: | 3E89C878.4040404@cvc.net |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
then do ( ( 6 * random() )::int ) % 6
Bruno Wolff III wrote:
> On Tue, Apr 01, 2003 at 11:26:47 -0500,
> Peter Choe <choepete(at)mindspring(dot)com> wrote:
>
>>thanks. i just tried it out and it seems that it would generate a
>>random number between 0 and 1. is that a valid assumption? if that is
>>the case, how can i cast it to an int value? i assume that there is a
>>cast function somewhere, but i can't tell by the names of the pronames.
>
>
> Normally you multiply by the range you want and then you can make a cast.
> Note however, that multiplication may cause a value to round up so that
> (6*random())::int might on very rare occasions return 6 instead of the
> expected 0, 1, 2, 3, 4 or 5. (At least on some systems.)
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2003-04-01 17:18:27 | Re: Log the SQL Statements |
Previous Message | Andrew Sullivan | 2003-04-01 17:07:28 | Re: About OIDs |