Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Return a random number.

 

Syntax

 

There are 3 possible syntax:

n = RND

n = RND(a, b)

n = RND(numeric_expression)

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

a

Number

No

Any numeric expression

b

Number

No

Any numeric expression

numeric_expression

Number

No

Any numeric expression

 

Remarks

 

RND function has 3 different calling syntax.

 

Extended numeric syntax:

RND executed without any parameters returns a random Extended-precision floating point value that is less than 1, but greater than or equal to 0.

Numbers generated by RND aren't really random, but are the result of applying a pseudo-random transformation algorithm to a starting ("seed") value.

Given the same seed, RND algorithm always produces the same sequence of "random" numbers.

 

Integer class numeric syntax:

RND(a, b) returns a Long-integer in the range of a to b inclusive.  a and b can each be a numeric literal or a numeric expression that evaluates within the full range of a Long-integer (-2,147,483,648 to 2,147,483,647). a can be higher or lower than b.

 

Special mode syntax:

When used with a single numeric expression argument, the value returned by RND depends on the numeric value you supply as the argument, as follows:

with a positive argument, RND generates the next number in sequence based on the initial seed value;

with an argument of 0, RND repeats the last number generated;

a negative argument causes the random number generator to be re-seeded, so subsequent uses of RND with no argument or with a positive argument result in a new sequence of values.

 

Restrictions

 

See also

 

Numeric functions, RNDF,

 

Examples

 

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software