RND

Contents


rnd(x) returns a random number, between zero (0) and x (excluding x).

 

Syntax

   rnd(num_exp)

 

Parameters

Element

Description

Restrictions

num_exp

Numeric Expression

None

 

Examples

   # Simulation of a throw of dice
    JET_DE = int(rnd(6)) + 1
 
   # Creation of an alphabetic string of a length of 10 randomly
    CH_HASARD = sigma(1, 10, chr$(int(rnd(25))+ASCII("A")))

 

Description and Comments

rnd(X) uses the function of the drand48() mathematical dictionary. The method used calls what comes next X(N+1)=A*X(N)+C (remainder M) with M=2^48, A=25214903917, C=11. The initial value given by Adonix at the startup depends on the local time.

The numbers obtained are distributed uniformly over the interval. If you wish to obtain integers, you may use one of the int, fix, or arr functions.

The result type is Double.

 

Associated Errors

Error

Description

ERMODE (10)

The parameter is not numeric.

 

Associated Keywords

INT - ARR - FIX


CONTENTS


Copyright © Sage 1999 - 2007