Description |
Gets the next positive floating point random number in the range 0.0 up to, but not including 1.0
|
|
Microsoft MSDN Links |
System
System.Random
|
|
|
Illustrating default and specified seeds |
program Project1;
{$APPTYPE CONSOLE}
var
rand : System.Random;
value : Double;
begin
Console.WriteLine('Using the default seed values start unpredictably :');
Console.WriteLine;
rand := System.Random.Create;
value := rand.NextDouble;
Console.WriteLine('Value 1 = {0}', value.ToString);
value := rand.NextDouble;
Console.WriteLine('Value 2 = {0}', value.ToString);
Console.WriteLine;
Console.WriteLine('Using 123 as the seed always produces these values :');
Console.WriteLine;
rand := System.Random.Create(123);
value := rand.NextDouble;
Console.WriteLine('Value 1 = {0}', value.ToString);
value := rand.NextDouble;
Console.WriteLine('Value 2 = {0}', value.ToString);
Console.ReadLine;
end.
| Show full unit code | Using the default seed values start unpredictably :
Value 1 = 0.449218966741682
Value 2 = 0.201625648048532
Using 123 as the seed always produces these values :
Value 1 = 0.984556915231308
Value 2 = 0.907815323168326
|
|
|
|