|
|
Topic complex |
Numerical functions |
Function |
random() |
Short |
Random number |
Syntax |
RANDOM(n : INTEGER) : INTEGER |
Parameter |
n : positive whole number |
Return |
Random number of the area 0 to n-1 |
See also: |
|
Description |
The random generator of the tdbengine returns statistically quite good distributed whole numbers.
The initialisation depends on system values like the time (system time).
Thus the sequence of the random numbers is normally not reproducible.
|
Example 1: Random
FROM a table DB a Random test with 10% of the records is made.
VAR test : TBITS[]
InitArray(test[FileSize(DB)])
WHILE NBits(test)<0.10*FileSize(DB) DO
test[1+RANDOM(FileSize(DB))]:=1
END
PutMarks(DB,test)
// now 10% of table are marked
|
Reproduzierbare Zufallsfolgen |
User: Thomas Seehaus | Date: 30.10.2004 21:34 | #3 |
Für manche Dinge ist es sinnvoll reproduzierbare Folgen zu erzeugen, indem der Generator z. B. über eine Prozedur "randomize" mit einem bestimmten Wert initialisiert.
Eine entsprechende Funktion würde ich mir für eine kommende tdbengine-Version wünschen.
MfG
Thomas Seehaus |
Write a comment:
|
|
|