From Clomosy Docs
ClomosyAdmin (talk | contribs) No edit summary |
ClomosyAdmin (talk | contribs) No edit summary |
||
| Line 42: | Line 42: | ||
<h2> See Also </h2> | <h2> See Also </h2> | ||
* [[System_Library#Math_Functions | Math Functions]] | * [[System_Library#Math_Functions | Math Functions]] | ||
{{#seo:|title=Random Using in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Use the Random function in Clomosy to generate floating-point random numbers between 0 and 1, or scale it for custom ranges like integers.}} | {{#seo:|description=Use the Random function in Clomosy to generate floating-point random numbers between 0 and 1, or scale it for custom ranges like integers.}} | ||
Latest revision as of 14:45, 24 December 2024
function Random: Extended;
The random function generates random numbers. These can be floating-point numbers in the following range:
0 <= Number < 1.0
It can be used by calling as follows. This call will generate a decimal random number value between 0 and 1.
x = Random();
If you want to get an integer value, define it as follows. Here it will return a random value between 0 and 100. After that, you can get values as you want.
x = Random() * 100;
Example
var
randomNumber,randomNumber2 : Integer;
{
randomNumber = Random();
randomNumber2 = Random() * 100;
ShowMessage(randomNumber);
ShowMessage(randomNumber2);
}
It assigns a different value with each execution. The output will not be the same.
To generate a random number where you can specify the start and end values, visit the GenerateRandom page.
Output:
0,197623564163223
52,8056032489985