Functions.Rand Method (Usual)
Return a random number between 0 and 1.
XSharp.RT (in XSharp.RT.dll) Version: 2.16
Syntax Request Example
nSeed AS USUAL
) AS FLOAT
public static Float Rand(
- Type: Usual
An optional start value.
This is the point at which the random number generator is initialized. Subsequent random numbers are then influenced by nSeed.
If you first call Rand() without nSeed, it starts as though 100001 were specified.
If you call the function with nSeed as 100001, it allows you to restart the generator.
Then, if you call the function several times without nSeed, it returns the "standard sequence" of numbers.
If nSeed is less than or equal to 0, the system time is brought into the process.
Rand() allows you to generate pseudo-random numbers. Multiple calls to Rand() always return the same random number sequence, provided that they have the same start value (nSeed) on the first call and that any subsequent calls do not specify nSeed.
This example uses Rand() to generate the same sequence whenever it runs:
This example generates the same start value as the previous example but subsequent calls accept a seed value which is also influenced by the system time:
This example generates a sequence of random numbers and then reinitializes to the same seed to reproduce the same numbers:
This example multiplies the result by 100 to increase the range of returned values: