Intrinsic Rand, what is the interval [0,1] or ]0,1] or [0,1[

Viewed 47

I use gfortran and I read in the doc (https://gcc.gnu.org/onlinedocs/gfortran/RAND.html) :
RAND(FLAG) returns a pseudo-random number from a uniform distribution between 0 and 1
I wonder if 0 or 1 are included and I am surprised but I could not be able to find this answer. I think I have not used the right keywords.
To check it, I wrote this simple program :

program main

real :: x   
integer :: i

do i=1,1000000000
    x =rand()
    if (x == 0.0d0 .or. x == 1.0d0) then
        print *,i,x
    endif
enddo     
end program main

On the output, only 0.00000 is printed.
So, could I conclude that the interval is [ 0.0 , 1.0 [ ? Or is it compiler, machine dependent, ... ? Is there a specification on rand() or not ?

0 Answers
Related