Rnd: Difference between revisions
Jump to navigation
Jump to search
Created page with "RND '''Description''' RND returns a single-precision number from a random sequence between 0 and 1. The value is always random: no seed needs to be supplied. '''Example'''..." |
|||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
''This function is for BASIC compatibility. It is not available in pure JavaScript projects.'' | |||
Rnd | |||
== Description == | |||
Rnd returns a single-precision number from a random sequence between 0 and 1. The value is always random: no seed needs to be supplied. | |||
== Example (Basic) == | |||
<pre> | <pre> | ||
Rem Rnd Example | |||
' | 'Rnd generates random numbers | ||
Random | Random | ||
Random | Random | ||
Random | Random | ||
Sub Random | |||
Dim Ret, i | |||
Ret = "" | |||
For i = 1 TO 4 | |||
Ret = Ret&(Int(100 * Rnd) +1) & " " | |||
Next | |||
Print "Four random numbers:", Ret | |||
End Sub | |||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
Four random numbers:6 71 1 19 | Four random numbers: 6 71 1 19 | ||
Four random numbers:33 28 4 51 | Four random numbers: 33 28 4 51 | ||
Four random numbers:33 28 4 51 | Four random numbers: 33 28 4 51 | ||
</pre> | </pre> | ||
== Related Items == | |||
[[Category:Language Reference]] | |||
[[Category:Math]] | |||
[[ | [[Category:BASIC Functions]] |
Latest revision as of 15:33, 25 March 2019
This function is for BASIC compatibility. It is not available in pure JavaScript projects.
Rnd
Description
Rnd returns a single-precision number from a random sequence between 0 and 1. The value is always random: no seed needs to be supplied.
Example (Basic)
Rem Rnd Example 'Rnd generates random numbers Random Random Random Sub Random Dim Ret, i Ret = "" For i = 1 TO 4 Ret = Ret&(Int(100 * Rnd) +1) & " " Next Print "Four random numbers:", Ret End Sub
Output
Four random numbers: 6 71 1 19 Four random numbers: 33 28 4 51 Four random numbers: 33 28 4 51