    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.


 

