Rand Function | |
Return a random number between 0 and 1.
Namespace:
XSharp.RT
Assembly:
XSharp.RT (in XSharp.RT.dll) Version: 2.21
Syntax Remarks
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.
Examples
This example uses Rand() to generate the same sequence whenever it runs:
1
2? Rand(100001.0)
3? Rand()
4? Rand()
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:
1? Rand(100001.0)
2? Rand(0.0)
3? Rand(0.0)
This example generates a sequence of random numbers and then reinitializes to the same seed to reproduce the same numbers:
1? Rand(100.0)
2? Rand()
3? Rand()
4? Rand(100.0)
5? Rand()
6? Rand()
This example multiplies the result by 100 to increase the range of returned values:
See Also