drand48() (and erand48) returns only zeros

Teun Burgers a.rburgers@quicknet.nl
Fri Nov 12 18:35:00 GMT 2004


meadmaker1066-cyg@yahoo.com wrote:

> drand48 and erand48 return only 0.0 no matter how many
> times I call them.

Indeed. Calling srand48 to set the seed helps, but should
not be necessary.

Teun

#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
     int i;
     srand48(0);
     for (i = 0; i< 20; i++) {
         printf("%3d %g\n", i, drand48());
     }
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list