RANDBETWEEN

The RANDBETWEEN function returns a random integer between two given values drawn from a discrete uniform distribution.

Syntax

RANDBETWEEN(
    bottom,
    top
)

Parameters
  • bottom: Lower value to be returned by the function.
  • top: Higher value to be returned by the function.
Returned value

The RANDBETWEEN function returns an integer.

Additional Information

The returned number will belong to the closed range [bottom, top]. That is, it can also take both values.

bottom must be less than or equal to top. If not, the function returns an error. Both bottom and top can be real numbers (the result will still be an integer between both values). If there are no integers between bottom and top, the function returns an error:

RANDBETWEEN function. Example of use

The bottom and top values can be less than zero (as long as the aforementioned conditions are respected):

RANDBETWEEN function. Example of use

Examples

The following example generates a random integer between the numbers 4.5 and 7.81 (that is, a random number 5, 6, or 7 is generated):

RANDBETWEEN function. Example of use

Related functions
Category
Mathematical and trigonometric
Submitted by admin on Tue, 12/04/2018 - 12:26