Jump to content

Futurebasic/Language/Reference/rnd

From Wikibooks, open books for an open world

Syntax

[edit | edit source]

randomInteger%

RND(expr%)

Description

[edit | edit source]

This function returns a pseudo-random long integer uniformly distributed in the range 1 through expr&. The expr& parameter should be greater than 1, and must not exceed 65536. If the value returned is to be assigned to a 16-bit integer (randomInteger%), expr& should not exceed 32767. The actual sequence of numbers returned by RND depends on the random number generator's "seed" value; see the RANDOM statement for more information. Note that RND(1) always returns the value 1.

Example: To get a random integer between two arbitrary limits min and max, use this statement: randomInteger = RND(max - min + 1) + min - 1 (Note: max - min must be less than or equal to 65536.) To get a random fraction, greater than or equal to zero and less than 1, use this statement: frac! = (RND(65536)-1)/65536.0 To get a random long integer in the range 1 through 2,147,483,647, use this statement: randomInteger& = ((RND(65536) - 1)<<15) + RND(32767)

See Also

[edit | edit source]

RANDOM; MAYBE