Re: [xml] EXSLT random() function

Chuck Bearden wrote:
Daniel Veillard wrote:
 Use the source, it's available !

static double
exsltMathRandom (void) {
    double ret;
    int num;

    num = rand();
    ret = (double)num / (double)RAND_MAX;

and man rand() states

       The  rand()  function  returns  a  pseudo-random  integer between 0 and

       The srand() function sets its argument as the seed for a  new  sequence
       of  pseudo-random  integers  to be returned by rand().  These sequences
       are repeatable by calling srand() with the same seed value.

       If no seed value is provided,  the  rand()  function  is  automatically
       seeded with a value of 1.

Thank you for your informative reply. I actually know less than you think I do :-) I did look at the source, and the syntax and logic were clear enough, but I haven't worked in C, and it didn't occur to me that I could 'man rand' since it is in the standard library. It's all perfectly clear when you know the conventions, and now I've learned a bit. The concern about portability makes perfect sense, and if time() is portable, then the solution in your follow-up reply makes sense to me as well.

P.S.: I will even try to create and test a patch for this, if you like.

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