Counting

I'm kind of obsessed with counting systems. Maybe it's to do with the computery things I do for a living, but for some reason I find them fascinating.

They are truly the language of nature. From the tiny acorns of 1+1=2 the mighty oaks of mathematics -and thus physics, the basis for much of our understanding of the natural world and modern lives- do grow.

So let's do some counting!

There are many counting systems but the best one we have come up with so far is known as the 'positional system' or 'place-value notation'. It's the one you use every day. Count up from 0-9 then carry the one, then count up from 0-9 again. This is base 10 because you count up 10 numbers before moving over one column. In computation we use binary which is a base 2 counting system. Simply count from 0-1 then carry the one then count from 0-1 again. Easy peasy!

16 8 4 2 1

 1 0 1 0 1

The binary number above is representing 1+4+16=21. Binary is useful because it only uses two charcters or states and can represent any number. That's how the computer you are looking at works by counting using high and low electrical signal to represent 1 and 0. It's all just fancy counting.

However, is difficult to store in memory. for example the number 100 would be 7 characters long, so for storing large numbers we need another system. Hexadecimal is a base-16 counting system. we use the characters 0-9 then A-F to count up to 15 before carrying the one.

eg.

256 16 1

  1  A F

The hex number 1AF represents (1*15)+(10*16)+(1*256) = 431

Hex is useful for storing large numbers in memory using few characters. eg FFF = 4095.

So how can we take this to it's logical extreme? Well to have larger base counting systems you just need more characters to represent numbers (in hex an A represents 10 for example) so looking at my keyboard I can see 69 different characters (including the space) so we could make a base-69 counting system with the space character (the last on my keyboard) representing 69.

here's an example:

 328509 4761 69 1

      C    A  T S

Cats represents (1*42)+(96*29)+(4761*41)+(328509*56) = 18 594 531

So why is this useful? Well you could encode messages in numbers for example, or if you had limited space for characters (such as with Twitter or SMS) it could be used to encode millions of unique links while using up only a few precious characters.

Comments

Popular posts from this blog

Never one to pass up a challenge...

Learning C++ (or programming Conway's Game of Life)

Binary Combination Lock