Re: [xslt] rand() .vs. random()



On Fri, Oct 08, 2010 at 11:07:34AM -0400, Phil Shafer wrote:
> The math:random() function ends up calling rand(), not random():
> 
> #if defined(HAVE_STDLIB_H) && defined(RAND_MAX)
> 
> /**
>  * exsltMathRandom:
>  *
>  * Implements the EXSLT - Math random() function:
>  *    number math:random ()
>  *
>  * Returns a random number between 0 and 1 inclusive.
>  */
> static double
> exsltMathRandom (void) {
>     double ret;
>     int num;
> 
>     num = rand();
>     ret = (double)num / (double)RAND_MAX;
>     return(ret);
> }
> 
> 
> Is this choice driven by portability?  Should we be using
> random() instead, since rand() gives cyclical data?  Or
> should we use the PRNG from openssh, if available?

 we had a thread about this earlier:

  http://mail.gnome.org/archives/xml/2008-February/msg00092.html

what is crucially needed is an srand initialization there, I think
that's the most important point, but we could detect random() from
configure and plug it in too.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]