« GAH! | Main | Referral Spam »

A Geek Revelation

I just had a revelation that has brightened my day considerably. While writing some code for a Base64 encoder/decoder, I was having a hard time visualizing the shifting of bits required to decode a Base64 string.

<AWTY™ Diversion>In a nutshell, Base64 is a method of encoding data in to ASCII characters for transmission. Base64 is used a lot in email since transmissions via email have to be text. Everything that's Base64 encoded consists of the characters A-Z, a-z, 0-9, +, and /. The equal sign (=) is used for padding. It's called Base64 because there are 64 characters (2^6) used in its makeup (not including the pad character).

As you can tell by the fact that it's 2^6, that means there are only 6 significant bits in each Base64 character. Computers aren't based around data types of 6 bits; they use bytes which are 8 bits. So you have some overlap. When encoding data in to Base64, you end up carrying over extra bits from the source data when creating the next Base64 character. When decoding Base64 text, it takes more than one Base64 character to create a single byte of source data. Although this may sound confusing, it's not too bad since there are only a finite number of carryovers that can be present before the pattern repeats itself. In the realm of coders, there is an obvious need for bit shifts (<< and >>).</Diversion>

While writing my decode function, I was having a hard time keeping track of the leftover bits from each Base64 character in my head. I tried scribbling down notes on my notepad, but that wasn't helping either. It was then that the perfect solution came to me. Eight full fingers - eight bits in a byte. It's pretty easy to visualize the bit shifts while staring at your digits planted on the desk in front of you.

This has led me to only one logical conclusion. God is a coder. I wonder which language He uses?

Comments (1)

Nice, God must have been a koder, and it looks quite a bit like he might have been into A.I. programming and fuzzy logic (or at least fuzzy animals, he sure made a lot of them).

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on January 9, 2004 3:57 PM.

The previous post in this blog was GAH!.

The next post in this blog is Referral Spam.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.34