Sunday, June 3, 2018

Number Systems and Conversions


Chapter: Fundamentals
Lesson: Data Representation in Computers
Lecture: Number systems and conversions


Data Representation in Computers


qIn this section we are going to learn about how things stored in a computer. As we know computer can store things we call “Data” in storage devices such as hard drives and in memory.

qAs we know a computer can store so many different type of data such as images, videos, text documents, data bases, etc. But there is one fundamental thing we should understand is that a computer can understand on zeros and ones (0 and 1).

qSo we need to understand how a computer store these all types of data using only 1 and 0. To understand this we need to study about number systems.

qHere we are going to learn about decimal, binary, octal and hexadecimal number systems.

Number Systems

qA number system is a way of representing numerical values. It’s a standard and the most common number system is decimal and we all are using the decimal number system for our day to day works.  Other number systems are Binary, Octal and Hexadecimal.

qA number system has a BASE (also called RADIX) and there are symbols to represent a digit. The number of digits in a number system is equal to the value (size) of the base.

qOur human mind is trained to use decimal number system. Computer uses binary number system. We use octal and hexadecimal number systems to represent small values or large and complex numerical values such as a very large amount.

Number System
Abbreviation
Base
Symbols
Decimal
Dec
10
0,1,2,3,4,5,6,7,8,9
Binary
Bin
2
0,1
Octal
Oct
8
0,1,2,3,4,5,6,7
Hexadecimal
Hex
16
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F


qDecimal (Dec) base value is 10 and there are 10 digits from 0-9
qBinary (Bin) base value is 2 and there are only two digits 0 and 1
qOctal (Oct)  base value is 8 and there are only 8 digits 0-7
qHexadecimal (Hex) base value is 16 and there are 16 digits 0-9 and A-F


Binary Number System


The binary number system has only two digits 0 and 1. The base of the binary number system is 2. Like decimal number system, the value of the digit in a binary number is depend on the position within the number. Let’s consider following binary number and convert in to decimal to get it’s decimal value.

Example:
101101 is a binary number.
Now the base of these digits are 2. So, let’s multiply digit from its radix and decimal value of it.
1x25 + 0x24 + 1x23 + 1x22 + 0x21 + 1x20  = 32 + 0 + 8 + 4 + 0 + 1
= 45

Octal Number System

Octal number system (short term Oct) has eight digits (0 – 7) and the base is 8. Since Oct numbers can contain digits from zero to seven, number 98 is not an Oct number and 478 is an Oct number because the base of the number is indicated as 8. Now let’s get the decimal value of 478 we do the same method used above.


Example:
4x81 + 7x80 = 32 + 7
= 3910

According to the above example 478 in Oct equal to 3910 in Dec.
Oct number system mainly use in computing. We will discuss in a later chapter when and where Oct system is used and some applications of it.

Hexadecimal Number System

Called Hex for short, this number system has 16 digits and mainly used to present large numbers. This contains digits from 0 – 9 and A – F for additional numbers. E1016 is a hexadecimal number. We can get the decimal value of this number using the same method we used previously.

The decimal value of English letters presented in Hex number system;

A = 10, B = 11, C =12, D = 13, E = 14, F = 15
Altogether (0 – F) there are 16 digits (including zero).

Example:
E1016 = 14x162 + 1x161 + 0x160
= 3584 + 16 + 0
= 360010

Number System Conversions

Decimal to Binary, Oct and Hex

qDecimal numbers may have an integer part and a fractional part. In number 454.67 integer part is 456 and fractional part is .67
qTo convert decimal number in to any other number system, we need to take these integer part and fractional part separately.

Converting integer part
§Divide the quotient repeatedly by the target base while recording remainders  until the quotient become zero or the quotient is less than the base value.
§Write the remainders from bottom to top order.


Example: 367.2310 to Bin

Convert fractional part

Repeatedly multiply the fractional part from the target base value while recording the integer value while the fraction becomes zero or until the required number of fractional positions met.

Write the integer values from top to bottom.

367.2310 = 101101111.00112

Bin, Oct, Hex to Decimal
To convert any Bin, Oct or Hex number to Dec is easy.  All you have to do is multiply base value of the position of the digit with digit value and get the sum of all values.

Lets convert 11101101.11012 to Decimal
1x27 +1x26+1x25+0x24+1x23+1x22+0x21+1x20.1x2-1+1x2-2+0x2-3+1x2-4

Note that 1x2-1 = 1 / 21 =0.5 and same method apply to others.
128+64+32+0+8+4+0+1   .   0.5+0.25+0+0.0625
= 237.812510 

Octal to Binary, Binary to Octal

qEach octal digit can be represented by equal three binary digits
qTo convert octal to binary, each octal digit should be replaced by binary digits
qTo convert binary to octal, binary number should separate in to three digit groups starting from the decimal place to both directions. Then replace by equal octal digit.

Convert 1000101102 to Octal
100 010 110
= 4268

Convert 3228 to binary
= 0110100102


Hex to Binary, Binary to Hex

qEach hex digit can be represented by equal four binary digits

qTo convert hex to binary, each hex digit should be replaced by binary digits

qTo convert binary to hex , binary number should separate in to four digit groups starting from the decimal place to both directions. Then replace by equal hex digit.


Binary Addition


Binary addition follows 4 simple rules as stated in below table.


Conclusions

Number systems, conversion and addition are the basics of computer technology. You need to have a good knowledge in this filed to understand different operations in CPU and programming.


This is also a very easy part to learn and takes little time and practice.

There may be questions from number system conversions and binary addition in the exam. These are the definite questions that you should answer and can gain full marks.

It takes very little time to answer questions from this area and you can save time for more difficult problems in the exam.

You can download the full slide here 
https://www.slideshare.net/susanthaherath/number-systems-and-conversions

No comments:

Post a Comment

Important Notice!

Dear students and friends. When you commenting please do not mention your email address. Because your email address will be publicly available and visible to all. Soon, it will start sending tons of spams because email crawlers can extract your email from feed text.

To contact me directly regarding any inquiry you may send an email to info@bcslectures.website and I will reply accordingly.