This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: drand48() (and erand48) returns only zeros
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/