From Clomosy Docs

No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
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.}}

Latest revision as of 14:45, 24 December 2024

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);
}

Output:

See Also