NYCPHP Meetup

NYPHP.org

[nycphp-talk] generate random unique 8-digit number

Chris Snyder chsnyder at gmail.com
Tue Mar 10 11:26:52 EDT 2009


On Tue, Mar 10, 2009 at 11:15 AM, Edward Potter <edwardpotter at gmail.com> wrote:
>
> Go down to Prince & Broadway, stop the first model that walks by, then the
> next, etc.  Ask them for a random number.  Believe me you will NEVER get the
> same number twice. And they will never repeat! All laws of Physics go
> straight out the window. Even Einstein gave in.
>
> Just my 2 rupee's
>

I asked a model how he did it, and he said he just looks at his watch
and then converts to unix micro time. I said, "That's not random!"

The model replied, "Yeah, but the kind of software developer who asks
a model for randomness is unable to tell the difference."

Add a random number to a sufficiently deep timestamp (microseconds)
and you will have a non-repeating random number. But you can't shorten
it to 8 characters or whatever -- you have to keep the full timestamp
in order to maintain non-repeatability.



More information about the talk mailing list