This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran] Implement irand(), rand(), and srand() for G77 compatibility
> 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