The rnd()
method is an inbuilt method in Euphoria that generates a random number between 0 and 1. This method randomly generates floating-point numbers between 0.0
and 1.0
(both inclusive).
This is unlike the rand()
method, which only returns integer numbers.
rnd()
This method has no parameters.
This method returns a random value between 0.0
and 1.0
, with both ends inclusive.
The code below shows how the rnd()
method generates a random floating-point number.
include std/rand.e--declare the variable to hold the outputatom output--use a for loop to print different floating numbersfor i = 1 to 6 doputs(1,"\n")output = rnd()print(1,output)end for
rand.e
module from the built-in library.for
loop.rnd()
method and print the outcome to the screen.