Subject | Re: [firebird-support] rand() of ib_udf not so random? |
---|---|
Author | Ivan Prenosil |
Post date | 2004-01-16T15:13:31Z |
> I have the following procedure that is intended to return fiveYes, you are using bad library :-)
> random numbers:
>
> CREATE PROCEDURE R_NUM_LIST
> RETURNS
> (
> RNUMBER DOUBLE PRECISION
> )
> AS
> begin
> rNumber=rand();
> suspend;
> rNumber=rand();
> suspend;
> rNumber=rand();
> suspend;
> rNumber=rand();
> suspend;
> rNumber=rand();
> suspend;
> end
>
> The records returned when I do a SELECT RNUMBER FROM R_NUM_LIST have
> always the same number, repeated five times, although it is different
> every time I run it.
>
> I'm doing something erroneously?
Here is the source code of the gem you found
double EXPORT IB_UDF_rand()
{
srand( (unsigned)time (NULL));
return ((float) rand() / (float) RAND_MAX);
}
Ivan
http://www.volny.cz/iprenosil/interbase/