Choose where you’d like to start

randomNumber

Overview

The randomNumber function generates a random number from the specified range.

Return Type

  • NUMBER
  • DECIMAL

Syntax

To generate a random number which falls in a specified range (inclusive of both values):

<variable> = randomNumber(<start_limit>, <end_limit>);
ParameterData typeDescription
<variable>NUMBER/DECIMALVariable that will contain a random number between the specified limits.
<start_limit>NUMBER/DECIMAL

The starting value of the range between which the random number needs to be generated.

Note: When the start limit, end limit, or both are decimals, the function returns a decimal. If both the arguments are whole numbers, the function returns a whole number.

<end_limit>NUMBER/DECIMAL

The ending value of the range between which the random number needs to generated.

Note: When the start limit, end limit, or both are decimals, the function returns a decimal. If both the arguments are whole numbers, the function returns a whole number.

Note: When using the random number function, please be aware that the random number generated can include the start limit and any numbers or decimals in between, but it will never be equal to the end limit.

Examples

response1 = randomnumber(1,3);    //returns 1 or 2
info response1;
response2 = randomnumber(1.789,34.54);    //returns a random decimal between 1.789 and 34.53
info response2;
response3 = randomnumber(5,123.4);     //returns a random decimal between 5 and 123.3 
info response3;
                

Get Started Now

Execute