How to do it? [ADVANCE]
#1

How to get an unique randomize number of a predefined length?
Reply
#2

the number "123456789" is 9 in lenght, so 10^9 in size as basis. you can do:
pawn Код:
100000000+random(900000000)
which gives any number ranging from 100000000 to 999999999. do this with 10^0:
1+random(9) equals 1,2,3,4,5,6,7,8,9, and
10+random(90) equals 10 to 99...
Reply
#3

Quote:
Originally Posted by Babul
Посмотреть сообщение
the number "123456789" is 9 in lenght, so 10^9 in size as basis. you can do:
pawn Код:
100000000+random(900000000)
which gives any number ranging from 100000000 to 999999999. do this with 10^0:
1+random(9) equals 1,2,3,4,5,6,7,8,9, and
10+random(90) equals 10 to 99...
thanks and one more question. How to generate the number until and unless it's unique?
Reply
#4

You would probably need to have it save numbers to a file, saving the last number used, then loading the next number.
Reply
#5

Quote:
Originally Posted by Deduction
Посмотреть сообщение
You would probably need to have it save numbers to a file, saving the last number used, then loading the next number.
I know, but how to do it on while loop. Cause there maybe more than 1 number on the file the random number generated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)