Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jan 1995 12:06:23 -0500
From:      Thomas David Rivers <ponds!rivers@dg-rtp.dg.com>
To:        freebsd-bugs@freefall.cdrom.com, freebsd-hackers@freefall.cdrom.com
Subject:   Serious problems in drand48().
Message-ID:  <199501181706.MAA15855@ponds.UUCP>

next in thread | raw e-mail | index | archive | help

I have run the following program on a Pentium and a 386sx-16 with
no floating point co-processor.

Both times it reported that drand48() incorrectly returned a value
greater than 1.0.

Of course, you're thinking - I haven't declared drand48() to return
a double - but there it is... 

drand48() should never return a value >= 1.0.

	- Dave Rivers -

----------- cut here (test case) ----------
double d;
#define COUNT 3072

double drand48();

main()
{
  int i;

  for(i=0;i<(COUNT*2); i++) {
        d = drand48();
        if( d > 1.0 ) {
                printf("d (%lf) is greater than 1.0\n", d);
        }
  }
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199501181706.MAA15855>