Rnd() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns a random number. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Rnd( list_type )

list_type selects the kind of random number list.

Return Value

A number of type float between 0 and 1 (exclusive).

Description

The Rnd() function returns a random floating-point number, greater than zero and less than one.

The conventional use is of the form Rnd(1), in which the function returns a random number. The sequence of random numbers is always the same unless you insert a Randomize statement in the program. Any positive list_type parameter value produces this type of result.

A less common use is the form Rnd(0), which returns the previous random number generated by the Rnd() function. This functionality is provided primarily for debugging purposes.

A very uncommon use is a call with a negative list_type value, such as Rnd(-1). For a given negative value, the Rnd() function always returns the same number, regardless of whether you have issued a Randomize statement. This functionality is provided primarily for debugging purposes.

Example

Chknum = 10 * Rnd(1) 

See Also:

Randomize statement