<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Rnd
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="rmdir+en">Previous</a>&nbsp;
<a href="rol+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Rnd
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><b>Rnd (</b> [ <u>Min</u> [ <b>,</b> <u>Max</u> ] <b>)</b></pre><p>

Computes a pseudo-random floating point number.
<p>
<ul>
<li>If no parameters is specified, returns a pseudo-random number in the interval [ <tt>0</tt> , <tt>1</tt> [.
<li>If the one parameter is specified, returns a pseudo-random in the interval [ <tt>0</tt> , <u>Min</u> [.
<li>If the two parameters are specified, returns a pseudo-random in the interval [ <u>Min</u> , <u>Max</u> [.
<p>
</ul>

Note that the higher born of the interval is never returned.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">' Between 0 and 1
PRINT Rnd
<hr>0.019539254718</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">' Between 0 and 2
PRINT Rnd(2)
<hr>0.040205506608</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">' Between Pi and Pi*2
PRINT Rnd(Pi, Pi(2))
<hr>3.204108046818</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">STATIC PUBLIC SUB Main()

  DIM Dice AS Integer

  Randomize

  Dice = Int(Rnd(1, 7))

  'Throws the dice between 1 and 6
  PRINT &quot;You threw a &quot; & dice

END</pre>
<p>
<hr><b>See also</b><br>
<a href="../cat/random+en">Random Numbers Functions</a>&nbsp;

</div>
</body>
</html>

