Little Endian Base 36 Sequence Numbers

If you only have a few files, it is best to give them descriptive names, e.g., tony_and_linda_at_the_prom.jpg. You would never confuse that file with tom_and_suzie_at_the_beach.jpg.

Let us suppose, however, that tony and linda have a few hundred photographs taken after the main party. They might be given names such as tl_after_prom_001.jpg through tl_after_prom_213.jpg. Incorporating actual descriptions in the places of the sequence numbers would be impractical: "tony and linda after the prom smiling broadly against a flower display background shot from about five yards away.jpg" would not be a good file name.

Even with sequence numbers you might have to type a lot before you get to the significant part of a file name. Wouldn't it make sense to put the numbers at the beginnings of the file names? ("213_tl_after_prom.jpg") That would make life easier if you were running from a command line with a file name completion feature. (You type "213" then hit the tab key and whatever is interpreting the command line automatically fills in the "_tl_after_prom.jpg" part.)

Unfortunately, there are only one thousand numbers with three decimal digits and if you go to four digits, well, that's more typing! In order to keep mindless key-stroking to a minimum, I decided to use base 36 little endian numbers.

In the base 36 numbering system, the numbers from 0 through 35 are all represented by a single digit, which is either a familiar digit like 0 or 9, or one of the letters from a to z. "z" in base 36 notation would be 35 decimal. "10" in base 36 notation would be 36 in decimal.

To further reduce typing, I turn these numbers around, making them "little endian," so called because the mathematically "least significant" digits come first. So the sequence number immediately following "f2b" is "g2b".

Thus, if I have generated 19 image files, say 7m3-tile.png through pm3-tile.png, and fm3-tile.png happens to be my favorite, then all I need to type to see it is "xiv" (my experimental image viewer), then a space, then "f", then a TAB. The command interpreter I use ("bash2") then fills in the "m3-tile.png" part and I'm all set. In fact, I could have, in one directory, up to 1296 files, each beginning with a unique two-character sequence.

If you want to look at some code, leb36.c is a grungy C program that increments a little endian base 36 number kept in a file. Little Secret Decoder is a grungy Perl program that prints out the decimal value of a three digit leb36 number supplied as an argument.

Happy increments!!
 
Copyright © 2003   You may make paper or electronic copies of this essay for your own enjoyment and edification.

If you wish to link to this article, try copying and pasting:

<a href="http://m3peeps.org/leb36.htm">Little Endian Base 36 Sequence Numbers</a>

[Go to m3peeps.org home page]

Read Manifesto for the Peoples of the Third Millennium