[comp.unix.i386] Random numbers problem under Bell Tech.

steve@hacker.UUCP (Stephen M. Youndt) (03/24/90)

Simply put, I compile this:
---
main()
{
  int i;
  srand48(7769);
  for (i=0; i<20; i++)
    printf("%g \n", drand48());
}
---
run it, get several numbers near to 0 (Ex: 8.32456E-315) then get:
---
Floating exception - core dumped
---
This is on Bell Tech SV3.2u with the BT S/W Dev Platform.   What the hell
am I doing wrong, and how do I fix it. Please mail answers directly to me.
Thanks in advance. -- SMY
-- 
Stephen M. Youndt         |  "By the time that we realize that ignorance
"Hacker at Large"         |   truely is bliss, it's already too late" -- ME

mea@funic.funet.fi (Matti E. Aarnio) (03/29/90)

In article <188@hacker.UUCP> steve@hacker.UUCP (Stephen M. Youndt) writes:
   Simply put, I compile this:
   ---
   main()
   {
     int i;
     srand48(7769);
     for (i=0; i<20; i++)
       printf("%g \n", drand48());
   }
   ---
   run it, get several numbers near to 0 (Ex: 8.32456E-315) then get:
   ---
   Floating exception - core dumped
   ---
   This is on Bell Tech SV3.2u with the BT S/W Dev Platform.   What the hell
   am I doing wrong, and how do I fix it. Please mail answers directly to me.
   Thanks in advance. -- SMY
   -- 
   Stephen M. Youndt         |  "By the time that we realize that ignorance
   "Hacker at Large"         |   truely is bliss, it's already too late" -- ME

Its generic C thing.  Add there statement telling:
  double drand48();
Now it should work.  Default value function return value is int as you
well know...

	/Matti Aarnio <mea@funic.funet.fi>
--
Matti E. Aarnio - Finnish University & Research Network project
<mea@funet.fi> <mea@mea.utu.fi> <mea@funic.funet.fi> <fys-ma@fintuvm.bitnet>
Turku University, WFTL, SF-20500 Turku, Finland -  +358-21-6335917
"Virtually, I don't work, I just netWORK :-)"