[comp.sys.amiga.tech] Lattice 5.04 problem with drand48??

scot@amigash.UUCP (Scot L. Harris) (11/06/89)

>        The first two programs I tried to compile under 5.04 both       
>crashed upon execution.  Using CodeProbe it looks like erand48          
>from lcm.lib is never returning.  The strange thing is that erand48     
>isn't even changed in lcm.lib.  I tried adding all the new and changed  
>modules by hand using oml, but the new lcm.lib still wouldn't work.     
>I went back to the 5.02 lcm.lib and everything works fine --- or at     
>least as good as it used to work.                                       
>                                                                        
>        ---Todd                                                         
>-=-                                                                     
>                                                                        
>Todd R. Johnson                                                         
>tj@cis.ohio-state.edu                                                   
>Laboratory for AI Research


Had similar results here.  Have not tried the old lcm.lib but suspect there is
some kind of problem with the floating point calculations.  Not sure if this
is true of all floating point stuff or just the random number generator.
I do know the following piece of code knocks the system down HARD.

If the drand48 is replaced by lrand48 it will work ok.

#include <stdio.h>
#include <math.h>                                                            
#include <time.h>

                                                                             
void main()                                                                  
{                                                                            
   double x;                                                                 
   long seed,y;                                                                
                                                                             

   time(&seed);         /* getting the time provides a varying seed value */ 
   printf("time ran and seed= %lx\n",seed);
   srand48(seed);        /* seed the random number generator */
   printf("seed has now been passed to srand48\n");               
   x = drand48();                                                            
   printf("Random number = %ld\n",y);                                         
}                                                                            


--
          _                                                                
    ///  /_\      Scot L. Harris !hoptoad!peora!{tarpit,rtmvax}!amigash!scot 
  \XX/  /   \ M I G A   	    		    
[If you can keep your head when all about you are losing theirs, perhaps
 you have misunderstood the situation.]