You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== rand ==
min/max, [max] |- ! scope="row" | Throws | [[../objects/ms.lang.RangeException|ms.lang.RangeException]]
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.0.1 |- ! scope="row" | Restricted |
The output might be:
The output might be:
The output might be:
Returns a random number from 0 to max or min to max, depending on usage. Max is exclusive. Min must be less than max. This will return an integer. If no arguments are given, a random double from 0.0 to 1.0 (exclusive) will be returned.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| rand
|-
! scope="row" | Returns
| mixed
|-
! scope="row" | Usages
| [] min/max, [max] |- ! scope="row" | Throws | [[../objects/ms.lang.RangeException|ms.lang.RangeException]]
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.0.1 |- ! scope="row" | Restricted |
No
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
rand([])
rand(min/max, [max])=== Examples === ====Example 1==== Basic usage, with one parameter Given the following code:
rand(10)
Copy Code
1 {{function|rand}}(10)
:5====Example 2==== Basic usage, with a range Given the following code:
rand(50, 100)
Copy Code
1 {{function|rand}}(50, 100)
:95====Example 3==== Usage with no parameters Given the following code:
rand()
Copy Code
1 {{function|rand}}()
:0.720543709668052
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)