drand48() (and erand48) returns only zeros

meadmaker1066-cyg@yahoo.com meadmaker1066-cyg@yahoo.com
Fri Nov 12 15:42:00 GMT 2004


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.

The mailinglist archives seem to have cases where
these functions are missing entirely or return errors,
but that's not the case here. In May 2004 the message
http://sources.redhat.com/ml/cygwin/2004-05/msg00050.html
describes a compiler error (and as per one reply to
that I checked and I'm not using "-mno-cygwin" flag).
In April 2001 a message states that the functions I'm
interested in are exported. Those are the only chains
that contain references to these functions and neither
(as far as my limited experience can tell) is the
problem I'm having.

I'm attaching my cygcheck output as suggested in the
mailinglist FAQ, but a summary of what seems relevant

Cygwin dll version 1.15.12-1 (so new it's still hot!)
gcc 3.4
Windows XP Home (Yuck, but no choice)

These versions are new because I had the problem with
older versions and updated to the latest gcc,
cygwin.dll, and libiconv2 (because gcc 3.4 complained
about it). I searched the packages and <cmath> and
<stdlib.h> seem to be part of cygwin.dll and gcc and
not seperate packages, so I'm guessing they are up to
date because I updated Cygwin.dll and gcc.

A simple test case is

#include <stdlib.h>
#include <cmath>

#include <iostream>
using namespace std;

...

for(int i=0; i<10; i++){
  printf("%f\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).

I tried grabbing source for glibc off the web, but
because the rand48 functions are tied into other
functions, renaming isn't trivial (for me - I tried
and the more I changed the more errors I got). Also,
because the rand48 functions do exist in CygWin, I get
name conflicts if I don't try to rename them.

So I'm out of ideas at this point, any answers or
hints in what direction to look would be greatly
appreciated.
Also, I've tried to do my homework on this one, but
I'm still pretty new to this so don't discount a
"really obvious" problem!

Thanks
Robert
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cyg.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20041112/c347329b/attachment.txt>
-------------- next part --------------
--
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/


More information about the Cygwin mailing list