Skip to content
Tristan Hume edited this page Apr 23, 2012 · 3 revisions

#Rand.Real

##Syntax Rand.Real : real

##Description The Rand.Real function returns a pseudo-random number in the range zero to one. For example, if x is a real number, after x := Rand.Real, x would have a value such as 0.729548 or 0.352879.

##Example This program repeatedly and randomly prints out Hi ho, hi ho or It's off to work we go.

    loop
        if Rand.Real > 0.5 then
            put "Hi ho, hi ho"
        else
            put "It's off to work we go"
        end if
    end loop

##Details The Rand.Real function sets its parameter to the next value of a sequence of pseudo-random real numbers that approximates a uniform distribution over the range 0<r <1.

Each time a program runs, Rand.Real uses a different pseudo-random number sequence. To always get the same sequence (actually, to start the sequence at the same point), use the Rand.Set procedure.

To use several sequences of repeatable pseudo-random number sequences, use the Rand.Seed and Rand.Next procedures.

##Status Exported qualified.

This means that you can only call the function by calling Rand.Real, not by calling Real.

##See also rand_int.html, rand_set.html, rand_seed.html and rand_next.html.

Clone this wiki locally