delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/12/14:04:08

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
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= ;
Message-ID: <20041112190357.86327.qmail@web52608.mail.yahoo.com>
Date: Fri, 12 Nov 2004 11:03:57 -0800 (PST)
From: <meadmaker1066-cyg AT yahoo DOT com>
Reply-To: meadmaker1066-cyg AT yahoo DOT com
Subject: Re: drand48() (and erand48) returns only zeros - SOLVED
To: cygwin AT cygwin DOT com
In-Reply-To: <Pine.GSO.4.61.0411121252480.1111@slinky.cs.nyu.edu>
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019