[comp.sys.amiga.tech] Lattice help - drand48

jimg@hp-ptp.HP.COM (Jim_Garrison) (02/02/90)

Hello everyone!

I have the Lattice 5.04a 'C' compiler, and I've been having a problem with
one of the supplied random number generators - drand48().  Does anyone know
if there's a known problem with this function?

#include <math.h>

main()
{
   double x;
   long t;

   time(&t);
   srand48(t);

   x = drand48();   /* BANG! Guru 0000003.xxxxxxxx */
}

Compiled with:

lc -Lm test.c


I also tried using erand48() with the same results as above.  

Any help would be appreciated.

Thanks a bunch,

Jim Garrison
Hewlett Packard
Industrial Automation Center

riley@batcomputer.tn.cornell.edu (Daniel S. Riley) (02/04/90)

In article <2290003@hp-ptp.HP.COM> jimg@hp-ptp.HP.COM (Jim_Garrison) writes:
>I have the Lattice 5.04a 'C' compiler, and I've been having a problem with
>one of the supplied random number generators - drand48().  Does anyone know
>if there's a known problem with this function?

This seems to be a popular problem...

This is a known problem with the 5.04 math libraries.  I *thought* that the
5.04a patch was supposed to fix it, and your example program worked fine
for me (no gurus).  You should double check that you installed all the
5.04a library patches correctly, especially the replacement for the CXV35
routine in lcm.lib.

For everyone else having this problem, get the 5.04a patch from Lattice,
either from their bulletin board, BIX (I guess), or call Lattice customer
service.

No, I have no affiliation with Lattice.

-Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley)
-Wilson Lab, Cornell University

rbabel@babylon.UUCP (Ralph Babel) (02/05/90)

In article <2290003@hp-ptp.HP.COM> jimg@hp-ptp.HP.COM (Jim_Garrison) writes:

> I have the Lattice 5.04a 'C' compiler, and I've been having a problem with
> one of the supplied random number generators - drand48().  Does anyone know
> if there's a known problem with this function?

The internal Lattice function _CXV25 has a bug.

To fix this problem, type ...

- OML LC:lcm.lib x cxv35
- DisAsm cxv35.o TO cxv35.a OPT X ;Metacomco's DisAsm!
- Add the line "MOVEM.L D2-D5/A1,-(A7)" right after the label _CXV25.
- ASM cxv35
- OML LC:lcm.lib r cxv35.o
- Recompile your example program (LC -Lm test), that's it!

Ralph

...!mcvax!uunet!cbmvax\
                       !cbmehq!babylon!rbabel
            ...!nccnet/