Numbers are a complex topic… a lot more complex than most people think.

There are a number of resources out there that explain how numbers work, their relationships to other numbers, base-10, etc., but not that many people seem to know these things. I have realized over the past few years that I have a pretty exceptional understanding of numbers among the people in the world not holding PhDs. To me, numbers are fascinating. Bases are fascinating. Math is fascinating.

Today I wrote a little program to help out a guy that I regularly tutor. It’s a simple program to demonstrate how to convert between any two arbitrary bases. It’s not a terribly complex program, and not terribly long. In fact it’s in total only about 50 lines of code. The core code of it is only about 30 lines. Numbers are just that… a representation of a numerical value.

If you take, for example, the number 123 in decimal (base-10), it could be represented a huge number of ways. None of them are necessarily more correct than any other. It just so happens that we normally use base-10 for day to day life. If we had been raised since birth in a society that used base-16, you might know the same number as “7b” instead. Or something else entirely. Numbers could be represented with different symbols. There can be any number of those symbols. The number of symbols chosen becomes the base of the number system.

Simple, right?

http://jcole.us/programming/bases.c is 404