Saturday, April 26, 2014

Number System

Good afternoon everyone! I was planning to write down something about Number systems from a long time now here it is. Four number systems, brief description of them and how to interchange these numbers.


Basic Number System

1. Decimal
2. Binary
3. Octal
4. Hexadecimal




Decimal:

It is the numerical base most widely used by modern civilizations. It is a 10 based number system. Total 10 number of digits are being used here. They are 0,1,2,3,4,5,6,7,8,9. Any of these numbers in this number system can be expressed in digits multiplied by base of 10 and its different powers. For example we can express
134.78 As 1*102 + 3*101 + 4*100 + 7*10-1 + 8*10-2
87.921 As 8*101 + 7*100 + 9*10-1 + 2*10-2 + 1*10-3

Binary:

In mathematics and digital electronics, a binary number is such a number expressed in the binary numeral system, or 2 based numeral system, which represents numeric values using two different symbols: typically 0 (zero) and 1 (one). Because of its straightforward implementation in digital electronic circuitry using logic gates, the binary system is used internally by almost all modern computers and computer-based devices such as mobile phones. We can easily express presence of electricity as 1 and absence of electricity as 0. So implementing Binary numeral system in electronics is really easy. Sometimes in logics 0 refers to false and 1 refers to True.

If we want to give an instruction to any computer it is hard for the computer to understand what we say, but it’s is easy for them to understand binary and we can also easily make them understand. That’s why it is widely used in machine code or the code that can a microprocessor execute.
So in binary system there is only two piece of information 0 and 1, each of them is called a bit. The word Bit came from Binary Digit. Bit is the fundamental unit.



A simple representation of a binary signal 1001011 can be shown like this. Here the 0 represents the low or 0Volt, and 1 represents the high or 5V. This is the way of communicating between computers or digital phones or even inside of the computer.

By this time you should be familiar with the words Byte, Kilobyte or Megabyte. What is a byte? A byte consists of 8 Bits or 8 Binary Digits. So, each 8 bit information will make 1 Byte of information and Kilobyte is simply 1000 times of this Byte. So, when you see a document file in your computer and say its size is 24KB (kilobyte) it means that document contains 24*100*8 Bit of Information in binary.

Note: Capital B is used for representing Byte and small b is used for Bit. Sometimes when your internet service provider tells you that you will get 512Kbps it actually means you will get (512/8) KBps = 64 KBps, that is you will be able to transfer 64Kilo byte of information each second.

Octal:

Octal number system is a Base-8 number system, hope you can guess it from its name. In octal 0, 1,2,3,4,5,6,7 these 8 numbers are used for displaying all the information. So why do we need octal? Just imagine if you want to represent a 12bit value, it will be pretty large but we can divide them into 4 groups each consisting of 3bits and then convert it to an octal number and we can represent that easily.

Octal became widely used in computing when systems such as the PDP-8 mainframe which employed 12-bit, 24-bit or 36-bit words. Octal was an ideal abbreviation of binary for these machines because their word size is divisible by three (each octal digit represents three binary digits). So four, eight or twelve digits could concisely display an entire machine word. It also cut costs by allowing Nixie tubes, seven-segment displays, and calculators to be used for the operator consoles, where binary displays were too complex to use, decimal displays needed complex hardware to convert radices, and hexadecimal displays needed to display more numerals. So octal makes displaying the information much easier comparing to binary.

So, simply if we use octal to represent something rather than binary it will be easier.

Hexadecimal 

Another short form of binary is hexadecimal. Hexadecimal consists of 16 digits. They are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. The main reason why we use hexadecimal numbers is because it is much easier to express binary number representations in hex than it is in any other base number system.
The physical address or mac address of your computer's network interface card is a hexadecimal value.




Comparison:



Conversion:

Simple Method – Using a scientific calculator. To demonstrate this I am using a very common scientific calculator Casio FX-991ES.

1st step: Go to the MODE and select BASE-N. This mode is used for calculating numbers of different base.



2nd step: Locate the buttons DEC, HEX, BIN, OCT, A, B, C, D, E, F on the calculator. Guess you already know that DEC, HEX, BIN, OCT stands for Decimal, Hexadecimal, Binary, Octal. And A-F will be used for entering hexadecimal values.

3rd step: Let’s try something. First press the HEX button. It will make the calculator ready for working with hexadecimal numbers. Type in something and press = sign. You can see now a Hex value is being shown in the display. Now if we want to convert it to Binary we will simply press the BIN Button. See? Now it’s showing the equivalent binary value. If we want to convert it to Octal or Decimal we would have to press OCT or DEC respectively.




You Can also use the default calculator of your windows system to do this type of calculation.

Open Calculator, Make sure it is in the View is in Programmer. Now you can just type in the digit. Make sure the radio buttons of the left side is in proper place.



Then you can just press another radio button and it will be converted. In the example here we can see that the Dec 25 is equal to Binary 11001. You can activate the Bin Radio Button to see that.


Manual Method – Sometimes we have to calculate values with decimal point. And a calculator like fx-991ES is not capable of doing so. In that case we can manually calculate it.

Binary:

To convert binary into a decimal we have to multiply by base 2 and its different power according to their positions. For example.


To convert Decimal to binary, for normal number we will just keep on dividing the number by 2 and then when the number becomes 0, we will just write down the remainder from bottom to top and we will find the number. For fraction, we have to multiply it by 2 and take the portion which is not in the fraction. We have to stop multiplying when the fraction part is 0. Here we will take from the top to bottom. Example


What if the fraction never ends? Then we will simply take a few digits after decimal point.


Octal

To convert octal into decimal we have to use the same rule that we used in converting binary and decimal. Just the base here will be 8. And its power will depend on the position of the digits. Example


To convert decimal into binary, we will use same rule, we will keep on dividing the digit by 8 and then write down the remainder in bottom to top order. For fraction we will keep on multiplying the fraction by 8 and take the portion without fraction. Example


If we have to convert binary into octal, we will just divide them into 3 bit and then convert them into octal. Example:


Hexadecimal 

From what you have seen so far, I guess it is very simple to understand how to convert from or into Hexadecimal.


You can also take 4bit of binary for each character and convert it.
Hope it was helpful. Have a nice day!

Read my other posts here.