Skip to main content

DESIGNING A RELAY COMPUTER: Understanding the Number System

For quite a while I have been trying to come up with a way to explain how the binary number system works, because its not really an intuitive way of dealing with numbers. If counting numbers is so easy why make such a complex way of dealing with them in a computer?? the answer is its easy to represent something in terms of ON or OFF than to have 10 different levels for representing the numbers.
From a very young age we are taught about numbers and how to count them. But learning that we have just accepted certain rules such as,
Zero is written as, '0'
One is written as, '1'
Two is written as, '2'
Three is written as, '3'
and so on....

If you think about it, these are just arbitrary symbols given to numbers from zero '0' to nine '9'. We have gotten used to calling these symbols as numbers that we don't realize this fact.

In our number System we have symbols from '0' to '9' i.e. ten symbols for ten numbers. Hence its called the decimal number system (its not the same as a decimal point, that's different) or, a number system in BASE 10.

So, in short we follow a number system that has a total of 10 symbols, the decimal number system.
Now, suppose we start counting in this system. Initially its easy and convenient, give each number a symbol. But as soon as you reach the number nine '9' you come across a problem!
The problem is that you have run out of symbols to assign...
I want to write ten but I don't have a symbol for that....hmmm.......
Oh! I know! I will just write a zero '0' and write a one '1' to my left. 
This one on the left is just a single digit number that tells me how many times I've run out of symbols for numbers on my right...!

AND THAT..... is the crux.... '10' is not a representation of the number ten, it tells us how many times we have run out of symbols to write a number.

Suppose we made our own unique number system with just three symbols i.e. BASE 3:
say,
zero is written as '0',
one is written as '#',
two is Written as '@',

So, in this way we can say:
0  +  #  =  #        and,
#  +  #  =  @
so if we started counting, we would get:
zero                0
one                 #
two                @
three            # 0    (ran out of symbols so did a carry #..)
four             # #
five             # @
six              @ 0  (ran out of symbols again, did a carry # again...)
seven          @ #
eight           @ @
nine           # 0 0  (ran out of numbers again..., so carry # over twice!)
ten             # 0 #
eleven       # 0 @
twelve       # # 0   (ran out of numbers again.... carry again......)
thirteen     # # #

So,
in base ten...... ten is      10  and hundred is 100 and thousand is        1000
in base three... three is #0 and nine is        #00 and twenty-seven is  #000

See the pattern here??

In BASE 10 adding zeroes to numbers shifts the numbers in powers of 10...i.e. 101, 102, 103 and so on....
In BASE 3 adding zeroes to the numbers shifts the numbers in powers of 3...i.e. 31, 32, 33 and so on...
So by changing the number of symbols we change how numbers are written...

Let's Talk Binary:

In digital computers we follow a binary number system i.e. BASE 2.
so, 
zero is         0
one is          1
two is        10
three is      11
four is     100
five is     101
six is       110
seven is   111
eight is  1000

this also means that adding zeros to the right of the numbers doubles the numbers i.e.
10 is  two i.e. 21
100 is four i.e. 22
1000 is eight i.e. 23
10000 is sixteen i.e. 24 and so on...

each digit is called a BIT (Binary digIT)....
One might also notice that as we reduce the BASE , the number of digits to write a number increase significantly,
for eg. writing in BASE 10 nine is;         9
but in our hypothetical BASE 3 nine is;  # 0 0,
and in binary or BASE 2 nine is;             1 0 0 1,

When working with computers at the machine level we need a system that makes it easier to write numbers since the numbers we will be dealing with will be really large in terms of a binary number. So, to make notation easy we can use a number system that has a base that is a power of 2 make conversions of numbers easy. But, let me tell you all about it some other post ;P
till then.......

Got any queries??? 
E-Mail me at: shashwath.sundar@gmail.com

Comments

Popular posts from this blog

DESIGNING A RELAY COMPUTER: Relays

In the previous posts I highlighted the various concepts that are fundamental to designing a computer. Now I think its time to mention the ways of practically applying these concepts to design a computer. The first thing I should highlight is that I will not be using transistors, I'll be using relays. This is due to the fact that its easier to understand how a relay works than to understand how a transistor works. Also, this seems to be the easiest way to understand how computers actually work since we are using mechanical switches instead of solid state switches (transistors). What is a Relay?? Relays are basically electrically controlled switches. Inside a relay is an electromagnet. when the electromagnet is powered, it attracts a metal strip that in turn operates a switch. Most widely available relays are SPDT relays or Single Pole Double Throw relays. In these relays the switch has 3 terminals- Common terminal , NO i.e. normally open terminal and NC i.e. normally ...

DESIGNING A RELAY COMPUTER: The Adding Machine

In a CPU there is circuitry dedicated to do all kinds of arithmetic operations and logical operations on binary numbers. Adders are circuits that reside in this ALU section of the CPU and they, as the name suggests, add numbers. So, how exactly does a circuit add binary numbers?? As I had previously mentioned in my post talking about number systems, certain properties of numbers remain the same regardless of the base of the number system. So, adding two binary numbers is similar to adding two decimal numbers. Lets first look at how we add decimal numbers. Suppose we were to add two 3 digit numbers: To add these two numbers first we add the numbers in the units place. Upon adding the two numbers we get either a single digit answer or a double digit answer. If the answer is a single digit it is considered the units digit of the final sum and we add the digits of the next place value. If the answer is a two digit number the units place of the answer is considered as ...

Making a URISC Processor: The Idea

So a while back I saw this video on Youtube by "Gary Explains" talking about a "One Instruction Set Computer". For those who do not know, a computer processor does a fixed set of things or follows a fixed set of instructions. Usually modern processors have hundreds of instructions. In the OISC or URISC (Ultimate Reduced Instruction Set Computer) processor the idea is to have one universal instruction that the processor executes that allows the programmer to write any program. The first time I heard of this idea I fell off my chair with excitement (Literally). My mind was really blown by the fact that you could write any program with just one instruction. So after going through what "Gary" on Youtube had to offer... I sat down and tried to come up with a design of this hypothetical processor that executes only one instruction. In the video Gary talked about a processor that executed an instruction called 'SUBLEQ' which simply means, SUB tract and th...