Friday, 7 September 2012

Alan Turing & How to Count in Binary Digits

I'm just in the process of moving some of my code samples into a GitHub repository. Whilst doing this I came across one of my projects called pJournal or "Python Journal" written in Python and WebPy as the web framework, which is essentially an extremely simplistic blog with the ability to post and display blog entries (nothing as great as blogger ;D)...

Nevertheless, as one of my entries into my own Python blog, I included the following summary on Alan Turing and then learnt how to count in binary:

Alan Turing - The Child Genius

Alan Turing, aged 23 (and who also shares my birthday of 23rd June!), created a definition of a Turing Machine which "is a two-way infinite tape, marked into squares. A machine has a scanner that looks at exactly one square of the tape at a time, has a finite number of states and a finite programme of instructions - with a begin state and an end state".

Turing worked out that by using this machine he describes, he could solve any mathematical problem. This gave rise then to mechanical computers which would solve mathematical problems with punch boards, and eventually to the invention of a transistor which holds the value either 1 or 0, and finally to computer machine code consisting of 1s and 0s. On top of this machine code more advanced programming languages have since been built which at their core are still just a series of finite states and instructions as per Alan Turing's definition.

(Read more here: http://en.wikipedia.org/wiki/Turing_machine).

How to Count in Binary Digits

So as part of my research into Alan Turing and binary code, I decided to learn how the binary system works. Base-10 is the human number system with numbers 0 - 9, whereas the computer system is base-2 with numbers 0 or 1.

First, lets imagine a virtual numbering system going on from right-to-left starting at column 0 and going onto column infinity, like so...

[infinity] ...6, 5, 4, 3, 2, 1, 0

For convenience, we shall call this virtual numbering system V.

The base-10 numbering uses: 10 to the power V, producing the following scale:


[infinity] ...1000000, 100000, 10000, 1000, 100, 10, 1

Similarly, the base-2 system uses: 2 to the power V, producing the following scale:

[infinity] ...64, 32, 16, 8, 4, 2, 1

Now it's easy to work out a base-10 number or a binary base-2 number - let's explore a few examples:

  • Why is the number twelve represented as 12 in base-10 format? Because under the base-10 scale to make up twelve we must have 1 ten and 2 ones, therefore producing the number 12.
  • Why is the number twenty represented as 20 in base-10 format? Remember in base-10 we only have nine numbers to play with. Therefore nineteen is made up of 1 ten and 9 ones. So to represent twenty, since we cannot have 1 ten and 10 ones (as we only have numbers 1 - 9) we then use 2 tens and 0 ones, producing the representation 20. Fascinating when you look at it this way right? Now let's move onto binary numbers.
  • What is the number twelve in binary base-2 format? Let's first look at the base-2 scale. The number twelve can be created with 1 eight, 1 four, 0 twos and 0 ones. Remember, in base-2 you can only have either 1 of a number or 0 (nothing) of a number. Therefore the number twelve in binary is 1100.
  • What is the number twenty in binary base-2 format? Twenty is made up of 1 sixteen, 0 eights, 1 four, 0 twos and 0 ones. Therefore producing 10100.
Now a little test for you! What is...
  • Thirty in binary?
  • Sixty nine in binary? (Hint: you may need to extend the example base-2 scale)

Finally, I spoke about the binary system with my brother Onkar and we agreed that it was very, very strange, and then my brother unknowingly but very relevantly made a joke "I don't like it one bit" hahaha! And on that note...goodbye for now!

No comments:

Post a Comment

Please leave your thoughts and comments!