This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: drand48() (and erand48) returns only zeros - SOLVED
- From: <meadmaker1066-cyg at yahoo dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 12 Nov 2004 11:03:57 -0800 (PST)
- Subject: Re: drand48() (and erand48) returns only zeros - SOLVED
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=2xUbbZOAas4FpaG6xiM1iYicp5xNFyBo+3wrNT1dqRR+G1mnvoQy/pkSlZsBB5nZFzdqodyXendgZ6W5Vl/VtBscDHIw9SD0Ansfw8gRkvtGe2bRTTjEKijMSxygSmVGzsnE+wALmaG+OeVyWE5jVYp7jzyUSUI2Be/F1oJ9gsY= ;
- Reply-to: meadmaker1066-cyg at yahoo dot com
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/