Click here to Skip to main content
15,911,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can we generate 14 digit numeric number.But that number should not repeat ever?
Posted
Comments
Chris Reynolds (UK) 15-Feb-13 5:38am    
Nowhere near enough detail to help. Start at zero and add one each time would work, but eventually you will run out of numbers. Each time your program starts should it carry on from where it left off? How do you plan to store the numbers you have already used. Please improve the question.
Zoltán Zörgő 15-Feb-13 5:49am    
You mean a 14 digit long random number?
Well, first of all it depend on the usage. If it is for cryptography need, than it is more complicated. Let's suppose you need it for general purpose, and let's suppose also, that you don't want to make them globally unique.

Random is random - it means that collisions can happen. The collision can be handled in two ways:
1) you generate the random number, and store it; the next time you generate a number, you check in the storage - if you have it already, you generate a new one.
2) you deal with the collision probability - is is acceptable at a level of let's say 1:2^200 ?

And there is an other question: how many instances do you want? Because you will run out of numbers after 10^14 instances.

So please clarify....
Logi Guna 16-Feb-13 2:07am    
what have you done so far?

The Guid Structure[^] may offer what you need.
 
Share this answer
 
In .net 4.0 this works:
C#
return new BigInteger(Guid.NewGuid().ToByteArray());
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900