GeneralUtilityWorkshop

GeneralUtilityWorkshop

GetRandomNumber

GetRandomNumber can be used to generate an unpredictable/random number from a given range. This service could be helpful when a random value is needed, such as a user’s initial password on user creation.

Once the service is dragged onto the Process Canvas, it is auto-filled with default values: minimum (1000000) and maximum (9999999).

The endpoints (Min and Max Values) of the range chosen are possible selections for the resulting Random Number.

GetRandomNumber Exceptions

The GetRandomNumber service expects the MinValue to be less than the MaxValue. If this is not true, an exception will be thrown. See the Exception Message below:

Varying Min and Max Digit Lengths

In both examples so far, the MinValue and MaxValue have been chosen so that the resulting random number is always the same number of digits. However, if the MinValue and MaxValue vary in number of digits, so can the results.

In this example, we have chosen a wide range:

The service has been run multiple times to demonstrate the possible outputs and their varying lengths.

 8 Digits

 9 Digits

 9 Digits

 9 Digits

 8 Digits

 8 Digits

 9 Digits

 9 Digits

Notice that even though all numbers between 1 and just short of a billion are possible, many 9 digits numbers are appearing and only a few 8 digit. This is because of the range chosen. Here is the count of how many numbers exist with each number of digits:

1 Digit

9 numbers

(1 - 9)

.0000009%

2 Digit

90 numbers

(10 - 99)

.000009%

3 Digit

900 numbers

(100 - 999)

.00009%

4 Digit

9,000 numbers

(1,000 - 9,999)

.0009%

5 Digit

90,000 numbers

(10,000 - 99,999)

.009%

6 Digit

900,000 numbers

(100,000 - 999,999)

.09%

7 Digit

9,000,000 numbers

(1,000,000 - 9,999,999)

.9%

8 Digit

90,000,000 numbers

(10,000,000 - 99,999,999)

9%

9 Digit

900,000,000 numbers

(100,000,000 - 999,999,999)

90%

So while it is possible to get a 1 digit number when generating a random number in the range from 1 to 999,999,999 is possible, it is unlikely because there is only a 9/999999999 (.0000009%) chance it will occur.

End Points Included

This example will show a tiny range to demonstrate that the end points are included in the selection range of the Random Number

Range of Negative Numbers

GetRandomNumber can also take negative numbers and input and pick a negative number as the RandomNumber.

Service Configuration:

Output: