delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/12/13:35:19

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
To: cygwin AT cygwin DOT com
From: Teun Burgers <a DOT rburgers AT quicknet DOT nl>
Subject: Re: drand48() (and erand48) returns only zeros
Date: Fri, 12 Nov 2004 19:35:29 +0100
Lines: 20
Message-ID: <cn2vo9$tac$1@sea.gmane.org>
References: <20041112154151 DOT 37720 DOT qmail AT web52604 DOT mail DOT yahoo DOT com>
Mime-Version: 1.0
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-Gmane-NNTP-Posting-Host: 84-104-25-136.cable.quicknet.nl
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
In-Reply-To: <20041112154151.37720.qmail@web52604.mail.yahoo.com>
X-IsSubscribed: yes

meadmaker1066-cyg AT yahoo DOT 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/

- Raw text -


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