This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: drand48() (and erand48) returns only zeros - SOLVED


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]