# Function 'RAND': equal number of digits in numbers

Colleagues, please tell me the answer to the following question!

If I use the RAND function with a range of output values greater than ten, is it possible to make it produce numbers with the same number of digits?
In other words, can RAND supplement the output number with zeros to the number of digits of the maximum value?

Well, for example,
not 1,2,3,4,5,6,7,8,9,10
but 01,02,03,04,05,06,07,08,09,10.
Or 001,002,003, … 100

Thank you in advance for your reply,
Ogogon.

Potentially you could try using a combination of MATH and RAND functions with variable manipulation to add a larger integer and then remove the leading digit:

`\${MATH(1000+\${RAND(1,100)},int):1}`

Variable maipulation:
https://wiki.asterisk.org/wiki/display/AST/Manipulating+Variables+Basics

These are not valid interger you will need to add then manually if rand value is smaller than 10, contactaning variables

If it’s just formatting you could try using the SPRINTF function.

https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_SPRINTF

Thank you. The method is witty. He reminded me of an old french anecdote about a strange but subtle perversion. (I really hope that I did not offend you!)

1 Like

Colleagues, thank you very much for your recommendations!
They helped me advance in solving the problem, but most importantly, I was able to appreciate the window of real opportunities.

Ogogon.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.