delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/11/12/12:55:32

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
Date: Fri, 12 Nov 2004 12:55:04 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: meadmaker1066-cyg AT yahoo DOT com
cc: cygwin AT cygwin DOT com
Subject: Re: drand48() (and erand48) returns only zeros
In-Reply-To: <20041112154151.37720.qmail@web52604.mail.yahoo.com>
Message-ID: <Pine.GSO.4.61.0411121252480.1111@slinky.cs.nyu.edu>
References: <20041112154151 DOT 37720 DOT qmail AT web52604 DOT mail DOT yahoo DOT com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

On Fri, 12 Nov 2004, meadmaker1066-cyg wrote:

> drand48 and erand48 return only 0.0 no matter how many
> times I call them. The code works fine on the Linux
> computers at school, and the compiler does not report
> any errors or warnings.
> [anip]
>
> #include <stdlib.h>
> #include <cmath>
>
> #include <iostream>
           ^^^^^^^^^^
If you're using C++, why use stdio functions?

> using namespace std;
>
> ...
>
> for(int i=0; i<10; i++){
>   printf("%f\n",drand48());

In any case, try

   printf("%lf\n",drand48());
            ^

> }
>
> In CygWin it produces a chain of 10 values "0.00000"
> but in Linux it produces a chain of random numbers. If
> I define an array of unsigned short integers and pass
> it to erand48 I get the same behavior (I thought maybe
> drand might be just resetting its internal storage).

HTH,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
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