A first stab at BaseN encoding with a focus on general alphabet encoding.

The comments in the code-only article are fairly decent, but I dislike being extremely verbose in my commenting because then I can't see my code. A little explanation of the problem is probably in order because of the lack of extremely verbose comments. First, what is base N encoding or alphabet encoding?

Most people assume that encoding into any base in some way equates to mapping a number to some digits, plus some additional characters to represent values we don't have digits for. This isn't always the case. An integer encoded as Alphabet{0,1} = 1001 = 9 decimal is identical to Alphabet{+,-} = -++- = 9 decimal. I've just change the represenation or alphabet, but the base is still the same (aka base 2).

Explaining bases could take a few years of college courses, as you take the concepts and create increasingly more abstract versions of them. In fact, bases are strange things in some theoretical maths where concepts of groups, colors, stripes, and other words are used to describe how they work. A very simplistic view of the base is available over on Mathworld. In general though, the concept is that any base has a number of digits equal to the base number b (aka radix) where the digits represent the values 0 through b-1. That is easy enough, and it gives us a very generic method for converting a number to any alphabet and back.

To start, we'll denote an alphabet as a char[] of digits. Digit in this sense is any character that will represent the array index at which it is placed. The base of the alphabet is the length of the character array. The first element in the array at offset {0} has a value of 0 and for all other indices n greater than 0 the value of the digit at n is equal to the index n. That's all there is to it. Any alphabet of characters can now be translated to and from an integer using this mapping table and the base.

Code-Only: Arbitrary alphabet encoding (aka BaseN encoding) for base2 through base36.

Published Sunday, November 07, 2004 3:45 PM by Justin Rogers
Filed under:

Comments

Sunday, April 10, 2005 8:03 AM by TrackBack

# re:A first stab at BaseN encoding with a focus on general alphabet encoding.

^_^,Pretty Good!
Friday, April 25, 2008 3:43 PM by math.kellyg@recursor.net

# re: A first stab at BaseN encoding with a focus on general alphabet encoding.

a few years of college courses?  come on, you mean a few hours

Wednesday, August 19, 2009 9:50 AM by medyum

# re: A first stab at BaseN encoding with a focus on general alphabet encoding.

a few years of college courses?  come on, you mean a few hours

Thursday, October 15, 2009 10:49 AM by poori

# re: A first stab at BaseN encoding with a focus on general alphabet encoding.

What application for windows will sync your notes from your iPhone back to your computer with the new 3.0 software? Any answers will help. Thanks!

________________

<a href="www.youtube.com/watch iphone</a>

Wednesday, October 21, 2009 1:33 AM by poori

# re: A first stab at BaseN encoding with a focus on general alphabet encoding.

Well my iphone finally did it died. I m leaving the states for a few months and i will need a knew phone, all stores near me are sold out of the iphone 3g S. So i was wondering what would be the easiest phone to grasp after using an iphone for a year.

________________

<a href="http://unlockiphone3g.webs.com">how to unlock iphone</a>

Leave a Comment

(required) 
(required) 
(optional)
(required)