Subject: Re: Base 36
Date: Thu, 28 May 1998 16:25:49 -0400
From: Alex Bogomolny

Dear Peter:

> We have a need to generate a unique random number that can never be duplicated.

How often you plan to generate it? And for how long should it stay unique? In other words, how many unique numbers do you expect to generate?

> We are thinking of using a combination of date and time
> down to the millisecond level

Unless you do this more often then at most once a millisecond this should work subject to the above.

> Perhaps
> base 36 might help. All ideas appreciated.

You realize that numbers in base 36 look more like strings than numbers, right. If you want to store and manipulate your random number as a number, I am not sure how converting it to base 36 may help.

> Number could be: 9836623595999 (YRDDDHHMMSSss)

That's fine. An important question is, Are you going to use it only as ID or it may be used in math calculations? What is actually your concern? To have a unique ID whose storage takes as little space as possible? If this is not the case, there is no reason to use base 36.

You do not need a conversion calculator to estimate how long the result may be. However, take into account that a char in base 36 will take at least 6 bits. A digit in bases 10-16 takes only 4 bits. The most economical (bitwise) storage is to use any base which is a power of 2. It does not matter which. So I would use base 16 and pack two digits into a byte. You can't do better than that. (In base 32 you would have to pack eight 5-bit digits into 5 bytes - much less straightforward.)

See, if you need a math consultant. I would be happy to stop by. I am a faithful cardholder of the NationsBank.

Best regards,
Alexander Bogomolny

|Reply| |Up| |Exchange index| |Contents| |Store|

Copyright © 1996-2012 Alexander Bogomolny

 41169613

A math books store at a unique math study site. Shopping at the store helps maintain the site. Thank you.
Sites for teachers
Sites for parents
Terms of use
Awards
Interactive Activities

CTK Exchange
CTK Wiki Math
CTK Insights - a blog
Math Help
Games & Puzzles
What Is What
Arithmetic
Algebra
Geometry
Probability
Outline Mathematics
Make an Identity
Book Reviews
Stories for Young
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
Visual Illusions
My Logo
Math Poll
Cut The Knot!
MSET99 Talk
Old and nice bookstore
Other Math sites
Front Page
Movie shortcuts
Personal info
Privacy Policy

Guest book
News sites

Recommend this site

Sites for parents

Education & Parenting

Search:
Keywords:

Google
Web CTK
Supported by
3wVentures