drand48() (and erand48) returns only zeros - SOLVED
meadmaker1066-cyg@yahoo.com
meadmaker1066-cyg@yahoo.com
Fri Nov 12 19:04:00 GMT 2004
Thanks Igor, Dave and Teun!
I was missing the call to srand48(0); that "unlocked"
both drand48 and erand48. My code (at least the random
number part) is now working.
In case anyone else is trying to do something similar
a working snippet is below.
Thanks to everybody who took time to help!
Robert
#include <iostream>
#include <math.h>
using namespace std;
int main(int argc,char* argv[]){
unsigned short FinishSeed[3]={1,2,3};
srand48(0); //Initializes seed AND multiplicand
for (int i=0; i < 10; i++){
printf("%g %g \n",drand48(),erand48(FinishSeed));
}
return 0;
}
--
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