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>

Wednesday, June 23, 2010 11:55 PM by cheap mlb jerseys

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

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.

Thursday, September 02, 2010 12:04 AM by whosale newera cap

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

Enjoy them ,share them ,latest new era hat fashion design at http://www.capssupplier.com

Saturday, March 05, 2011 1:17 AM by Sara Meetington

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

It was rather interesting for me to read that article. Thanx for it. I like such themes and everything connected to this matter. I would like to read more on this blog soon.      

Sara  Meetington    

<a href="www.jammer-store.com/">mobile phone jammer circuit</a>

Wednesday, March 16, 2011 6:54 PM by Brandy Stepman

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

It was certainly interesting for me to read the article. Thanks for it. I like such themes and anything connected to this matter. I would like to read more on this site soon.        

Brandy  Stepman      

<a href="rome-escort.info/">escort girls a roma</a>

Thursday, March 24, 2011 10:04 PM by Nicky Meetington

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

It is certainly interesting for me to read the post. Thanx for it. I like such themes and everything that is connected to this matter. I would like to read a bit more on that blog soon.        

Nicky  Meetington        

<a href="www.phone-blocker.com/">phone jammer uk</a>

Thursday, April 07, 2011 5:34 AM by mulberry handbags

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

Mulberry Outlet Store is a top brand in the UK. Our Mulberry bags offers all kinds of mulberry sale with unique design and fashion style. What's more, the Mulberry Bags are on sale now, you can find any latest design that you are looking for here, and get them at the best price.

Come here, you will find a best mulberry factory shop. mulberry handbags is one key point of our Mulberry outlet shop. Discount Mulberry sales are on at the moment.

Friday, April 08, 2011 3:20 AM by Jenny Karver

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

It was certainly interesting for me to read this post. Thank author for it. I like such topics and everything connected to them. I would like to read a bit more on this blog soon.          

Jenny  Karver          

<a href="milanescorts.com/">accompagnatrice escort cinese milano</a>

Saturday, April 16, 2011 9:53 PM by Sara Stone

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

It was certainly interesting for me to read this post. Thanks for it. I like such themes and everything that is connected to this matter. I would like to read more soon.            

Sara  Stone          

<a href="www.baccaratgirls.com/">escort UK</a>

Wednesday, April 27, 2011 2:23 PM by Mary Flouee

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

It was certainly interesting for me to read this blog. Thanx for it. I like such topics and everything connected to this matter. I definitely want to read more on this site soon.            

Mary  Flouee            

<a href="monacoescort.com/">monaco call girls</a>

Thursday, August 11, 2011 3:21 AM by coach outlet

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

I read with great interest.Thanks for you sharing.

Saturday, October 29, 2011 3:16 AM by OEM software online

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

LArVHv I read online (computer problems) positive feedback about your resource. Didnt even believe it, and now saw myself. It turned out that I was not fooled!...

Saturday, November 05, 2011 4:56 PM by Download oem software

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

Yg15RX Left on my site a link to this post. I think many people will be interested in it..!!

Leave a Comment

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