[gfortran] Implement irand(), rand(), and srand() for G77 compatibility

Paul Brook paul@codesourcery.com
Sun May 30 23:50:00 GMT 2004


> irand(i) returns a value in the range [1,GFC_RAND_M-1].
> irand(i) - 1 is in the range [0,GFC_RAND_M-2].  So, the
> division above is in the range [0,1).

You're forgetting that real*4 has significantly less than 32 bits precision, 
so is unable to accurately represent integers of this magnitude. After 
rounding the result will in the range [0-1]

Paul



More information about the Fortran mailing list