Page 1 of 1

base 36 Numbering

Posted: Mon Jul 04, 2005 10:45 pm
by harrisonad
I am auto-generating a number system to be stored in the database which increments by one like an auto_increment field. But the twist is, I am including [0-9] and [A-Z] in this number system.
Just like Hex Numbering which gives

Code: Select all

00008
00009
00000
0000A
0000B
// .. upto
0000F
00010
But I want to include all remaining letters, [G-Z], which must give...

Code: Select all

0000W
0000X
0000Y
0000Z
00010
I tried to modify a function for hex then changing the base number to 36, but It sucks with all the bugs.
Any idea how can I do this perfectly or almost?

Posted: Tue Jul 05, 2005 1:55 am
by timvw

Posted: Tue Jul 05, 2005 2:02 am
by harrisonad
Ooops! seems like I will reinvent the wheel again... :oops:

Posted: Tue Jul 05, 2005 2:08 am
by Syranide
there is something similar in php too, base_convert or something like that.

EDIT: why would you ever want to store that string in the database?

Posted: Tue Jul 05, 2005 2:33 am
by harrisonad
This serves as tracking number for Requests made by, let's say, remote store branch to main office. Well, i can be contented with auto_increment database column or using md5() or hash() to generate alpha numeric for me, but I want it incremented.