Rnd: Difference between revisions

From NSB App Studio
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'''...")
 
No edit summary
Line 1: Line 1:
RND
Rnd


'''Description'''
== 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.
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'''
== Example ==


<pre>
<pre>
REM RND Example
Rem Rnd Example
'RND generates random numbers
'Rnd generates random numbers
Random
Random
Random
Random
Line 15: Line 15:
   
   
SUB Random
SUB Random
   DIM Ret, i
   Dim Ret, i
   RET = ""
   Ret = ""
   FOR i = 1 TO 4
   For i = 1 TO 4
       RET = RET&(INT(100 * RND) +1) & " "
       Ret = Ret&(Int(100 * Rnd) +1) & " "
   NEXT
   Next
   PRINT "Four random numbers:", RET
   Print "Four random numbers:", Ret
END SUB
End Sub
</pre>
</pre>


'''Output'''
== Output ==


<pre>
<pre>
Line 32: Line 32:
</pre>
</pre>


'''Related Items'''
== Related Items ==


[[randomize|RANDOMIZE]]
[[randomize|RANDOMIZE]]
[[Category:Language Reference]]

Revision as of 02:59, 17 August 2012

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

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

Related Items

RANDOMIZE