CRE Programmer's Guide
Math Functions
Common Run-Time Environment (CRE) Programmer’s Guide—528146-004
7-17
Random_Set, Random_Next
i := 3;
s := RTL_Power2_Real64_(r, i); ! s gets 56.0L0
Random_Set, Random_Next
The Random_Set function sets a seed—the value of the initial random number—for a
pseudo-random number generator. The Random_Next function returns the next
pseudo-random number in the current sequence. These functions are not available in
the native CRE library.
seed
is the beginning number of the pseudo-random number sequence.
Considerations
•
Each call to CRE_Random_Set_ establishes a new seed value.
•
Each call to CRE_Random_Next_ returns the next pseudo-random number in the
current sequence.
Round
The Round functions return the nearest whole number to their parameter. These
functions are not available in the native CRE library.
number
is the number to round.
Return Value
The Round functions return:
truncate(
number + 0.5 ) if number is greater than or equal to 0
truncate(
number - 0.5 ) if number < 0
PROC CRE_Random_Set_( seed );
INT seed; ! in TNS only
INT PROC CRE_Random_Next_; ! TNS only
REAL(32) PROC RTL_Round_Real32_( number );
REAL(32) number; ! in TNS only
REAL(64) PROC RTL_Round_Real64_( number );
REAL(64) number; ! in TNS only