Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views14 pages

ch3 1

Chspter 1

Uploaded by

hilina aschalew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views14 pages

ch3 1

Chspter 1

Uploaded by

hilina aschalew
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

CHAPTER 3

Data Representation and Numbering System

3.1. Data Representation inside Computer System


We know that a computer is an electronic device i.e. it works using electrical signals. Electrical signals
can represent only two states; on (1) and off (0). Thus, any information that has to be processed by a
digital computer has to be converted in to a format which has two states (0 and 1). In digital information
processing, we use the binary number system which has two digits. In other word, computer processes
any types of data using binary numbers. Thus, after the input data entered in to the computer or any code
that is written either high or middle level language (assembly language) for processing, it must be
converted in to its equivalent binary form. The most extensively used number systems are of two types:
none-positional and positional.
3.2. Units of Data Representation
When data is stored, processed or communicated within the computer system, it is packed in units.
Arranged from the smallest to the largest, the units are called bit, byte and word;
These units are based on the binary number system;
1. BIT
Bits are the smallest units and can convey only two possible states 0 or 1. Bit stands for binary digits.
A bit is a single element in the computer, on a disk that stands for either “ON” indicating 1 or “OFF”
indicating 0.
In the computer “ON” is represented by the existence of current and “OFF” is represented by the non-
existence of current.
On a magnetic disk, the same information is stored by changing the polarity or magnetized particles on
the disk‟s surface.
2. BYTE
Bits can be organized into large units to make them represent more and meaningful information. This
large unit is called a byte and is the basic “unit of data representation” in a computer system. The
commonly used byte contains 8 bits.
Since each bit has two states and there are 8 bits in a byte, the total amount of data that can be
represented is 28 or 256 possible combinations.
Each byte can represent a character (a character is a letter, a number or a special symbol such as +,-,?,*,
$, etc. A byte is then used as a unit of measurement in the computer memory, processing unit, external
storage and during communication;

1 Introduction to comp. application


If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where KB stands
for kilobyte.
1 Kilobyte (1KB) is 2 10 or 1024 bytes
1 Megabyte (MB) is 2 20 bytes or 2 10 kilobytes
1 Gigabyte (GB) is 2 30 bytes or 2 20 kilobytes or 2 10 megabytes
3. WORD
Word refers the number of bits that a computer process at a time or a transmission media transmits at a
time. Although bytes can store or transmit information, the process can even be faster if more than one
byte is processed at a once. A combination of bytes, then form a “word”. A word can contain one, two,
three or four bytes based on the capacity of the computer; Word length is usually given in bits
We say that a computer is 8-bits, a 16 bit, a 32 bit or a 64 bit computer to indicate that the amount of
data it can process at a time. The large the word length a computer has the more powerful and faster it
is. We enter data into a computer or review (see) output data from a computer using the letter of
alphabet, various special symbols, and the numerals in the decimal number system. But since computer
is an electronic device, which understands electrical flow (signal) there is no letter, symbol or number
inside the computer. Computer works with binary numbers. As a semiconductor is conducting or isn‟t
conducting; a switch is closed or opened.
So data are represented in the form of a code that can have a corresponding electrical signal.
Computers are built from components that have two values; on/off
The binary number system, which has only two digits 0 and 1 is used to express the two states
Internal arithmetic operations of a digital computer are actually performed in binary number system.
o Binary numbers Can represent character data or numeric data
 Characters may be classified as:
 Letters and/or digits (A-Z, a-z, or 0-9)
 Special symbols such as: ?, *, +
 Control characters (which control devices)
 When characters are used in computer, they must be converted into a binary string (sequences of
0‟s and 1‟s)
 There are several codes for converting data into binary string:
E.g
o ASCII (American Standard Code for Information Interchange)
o EBCDIC (Extended Binary Code Decimal Interchange Code)
o BCD ( Binary Coded Decimal

2 Introduction to comp. application


 In ASCII code, a character is represented by 7 bits - maximum of 27 different characters out of
which 96 are printable and 32 non printable
o E.g ASCII code of A=65=1000001
 EBCDIC uses broader numerical range (0-255)
o Uses 8 bits to represent a character
o E.g EBCDIC code of A= 193=11000001

3.3. None-Positional Numbering System


It is familiar with Roman Notation System. In this system, each symbol represents the same value
regardless of its position in the number and the symbols are simply added to find out the resultant value
of a particular number. That is why this number system works in some traditional additive approaches.
3.4. Positional Numbering System
In a number system, there are only few symbols which represent different values depending on their
positions. The total number of different fundamental digits applicable to a number system is called its
radix or base. The most widely used number system is the positional number system. In this number
system, the position of a digit indicates the significance / weight to be attached to the digit. The positional
number systems are binary, octal, decimal, and hexadecimal.
Computer has been designed to use binary numbers because of the following reasons:
a) Computer circuits are designed on the basis of two bits 0 & 1. The digital electronic circuits have
only two possible states. Due to this feature of electronic circuits, a computer can understand
information composed of only 0s and 1s i.e. all the internal operations/manipulations are performed
in binary form.
b) Every operation that can be done in decimal system can also be done in binary.
c) The binary system simplifies the design of the circuits, reduces the cost and improves the reliability.
d) The earliest forms of input and storage devices were developed in a way to accept binary numbers.
For instance, punched cards.
3.5. Number System
A number system is a set of symbols used for counting. When we type some letters or words, the
computer translates them in numbers. Because computers can understand only numbers. A computer
can understand the positional number system where there are only a few symbols called digits and these
symbols represent different values depending on the position they occupy in the number. There are
various number systems.
Example: Decimal, Binary, octal-decimal, hexadecimal etc.

3 Introduction to comp. application


3.5.1. The Decimal Number System
It is the most popular form of numbering system which is used by human being. The Decimal number
system is based on ten different digits (0-9) 0,1,2,3,4,5,6,7,8,9. Its radix is 10. We say it is a base ten
number system. Though it is widely used, it is inconvenient for computer to represent data. So we need
another number system.
3.5.2. The Binary number system
Binary number system is based on the two different digits; 0 and 1. Sometimes it is also called base-
two system. The most popular form which is understood by the computer. Its radix is 2. It is important
to note that every decimal number system has its equivalent binary number. Conversion from binary to
its equivalent decimal and from decimal to its equivalent binary is possible. Operation on binary
number system is also possible. e.g. (110101)2
Binary 000 001 010 011 100 101 110 111 1000 1001 1010 1011 1100
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 Etc...
Example:- Binary Number: 101012 , Calculating Decimal Equivalent −
Step Binary Number Decimal Number
Step 1 101012 ((1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20))10
Step 2 101012 (16 + 0 + 4 + 0 + 1)10
Step 3 101012 2110
Note − 101012 is normally written as 10101.
3.5.3. Octal number System (base 8) (Oct)
It uses 8 digits 0-7 (i.e. 1, 2, 3, 4, 5, 6, and 7.) to represent numbers, as 23 =8. The radix of octal is 8.
Like binary number system it is complete number system. It uses eight digits, an octal number is
represented by a set of 3 bits. e.g. (5)8= (101)2
Example: 77 in octal equals 63 in decimal and 111111 in binary.
Example:- Octal Number: (12570)8 ,Calculating Decimal Equivalent −
Step Octal Number Decimal Number
Step 1 125708 ((1 x 8 ) + (2 x 83) + (5 x 82) + (7 x 81) + (0 x 80))10
4

Step 2 125708 (4096 + 1024 + 320 + 56 + 0)10


Step 3 125708 549610
Note − 125708 is normally written as 12570.
3.5.4. Hexadecimal number system (16) (hex)
The hexadecimal system is based on the binary system using a Nibble or 4-bit boundary. It uses 16
symbols to represent numbers. These symbols are including only the digits 0 through 9 and the letters
A, B, C, D, E, and F for the numbers starting from 10 to 15 respectively. Uses base 16. Letters
represent the numbers starting from 10. A = 10. B = 11, C = 12, D = 13, E = 14, F = 15.
Example: - Hexadecimal Number: 19FDE16
Calculating Decimal Equivalent –

4 Introduction to comp. application


Step Binary Decimal Number
Number
Step 1 19FDE16 ((1 x 164) + (9 x 163) + (F x 162) + (D x 161) + (E x 160))10
Step 2 19FDE16 ((1 x 164) + (9 x 163) + (15 x 162) + (13 x 161) + (14 x 160))10
Step 3 19FDE16 (65536+ 36864 + 3840 + 208 + 14)10
Step 4 19FDE16 10646210
Note − 19FDE16 is normally written as 19FDE.
3.6. Conversion from one Base to Another
The values that numbers have with a given number systems are largely determined by their positional
notation. Positional notation means that the position of one symbol relative to other symbols in a given
number system determines the value of that symbol. For example, the symbols 5 &4 can represent
either 54 or 45 depending upon their relative position to one another.
S.No From To base Method
base
1 2 10 Expand binary number in powers of 2
2 10 2 Divide the decimal number by 2 until the reminder becomes zero or impossible to
be divided by 2.
3 2 8 Group 3 binary digits together (preferable) but you can go from 2108
4 8 2 Each Octal digit is converted to 3 binary digits (preferable and simplest method)
but you can go from 8102
5 2 16 Group 4 binary digits together (preferable and simplest method) but you can go
from 21016
6 16 2 Each hexadecimal digit is converted to 4 binary digits(preferable and simplest
method) but you can go from 16102
7 8 10 Go from 8210 or Expand the octal number in power of 8.
8 10 8 Go from 1028 or divide the decimal number by 8 until the quotient becomes
zero.
9 16 10 Go from 16210 or Expand the hex-decimal number in power of 16.
10 10 16 Go from 10216 or divide the decimal number by 16 until the quotient
becomes zero.
11 8 16 Go from 8216 (preferable and simplest method) but you can go from
81016
12 16 8 Go from 1628 (preferable and simplest method) but you can go from
16108

5 Introduction to comp. application


The decimal number 135 can be expanded as:
2 1 0
(135) 10 = 1*10 +3*10 +5*10

The number 10 in binary is not the same as 10 in decimal because the value of 1 in the binary is not the
same as the value of the 1 in decimal.
3.6.1. Conversion from decimal (base 10) to other bases (base M)
To convert a decimal number X to a number in base m, divide X by m, store the remainder, again
divide the quotient by M, store the remainder, and continue until the quotient becomes 0. And
concatenate (collect) the remainders starting from the last up to the first.
3.6.1.1. Decimal to Binary
The following example shows the step-by-step process converting decimal number to binary.
Example 1 :-Decimal Number: 2910 ,Calculating Binary Equivalent −
Step Operation Result Remainder
Step 1 29 / 2 14 1
Step 2 14 / 2 7 0
Step 3 7/2 3 1
Step 4 3/2 1 1
Step 5 1/2 0 1

The remainders have to be arranged in the reverse order so that the first remainder becomes the Least
Significant Digit (LSD) and the last remainder becomes the Most Significant Digit (MSD).

Decimal Number: 2910 = Binary Number: 111012.


Example 2:- Let’s convert 11.37510 to binary.
Part 1 converting decimal part
Step Operation Result Remainder
Step 1 11 / 2 5 1
Step 2 5/2 2 1
Step 3 2/2 1 0
Step 4 1/ 2 0 1
Part 2 converting fractional part
Step Multiply by 2 Product Whole No.
Step 1 2 x 0.37510 0.75 0
Step 2 2x 0.75 1.50 1
Step 3 2x 0.5 1.00 1
Done Converted fractional No. (0.110)2

Part 3 combine the two components and gives (11.37510)10=(1011.011)2


Example 1:- Convert 5610 to binary
(56)10 = (111000)2
6 Introduction to comp. application
Example 2. Convert 7810 to base 8 (Octal) Ans. (78)10=(116)8
3.6.1.2. Decimal to Octal
Let‟s convert decimal to octal with an accuracy of four fractional digits. When converting the fractional
components of the number, the algorithm is continued until four digits worth of fractional numerals
have been achieved. Once the accuracy has been achieved, the conversion is finished even though a
product with a zero fractional value has not been obtained.
Example 1:- Let’s convert (10.4)10 to octal with an accuracy of four fractional digits.
Part 1 converting decimal part
Step Operation Quotient Remainder
Step 1 10 /8 1 2
Step 2 1/8 0 1
Converted No. (12)8
Part 2 converting fractional part
Step Multiply by Product Whole No.
2
Step 1 8x 0.4 3.2 3
Step 2 8x 0.2 1.6 1
Step 3 8x 0.6 4.8 4
Step 4 8x 0.8 6.4 6
Converted fractional No. (.3146)8

Part 3 combine the two components and gives (10.4)10 =(12.3146)10

3.6.1.3. Decimal to Hexadecimal


When doing this conversion, all of the divisions and multiplications are done using decimal. If the
results end up between 1010 and 1510, then the decimal numbers are substituted with their hex symbol
equivalent (i.e., A to F). Example below shows the step-by-step process of converting a decimal
number to hex with a fractional accuracy of three digits.
Example 1:- Let‟s convert 254.65510 to hexadecimal with an accuracy of three fractional
digits.
Part 1 converting decimal part
Step Operation Quotient Remainder
Step 1 254 /16 15 (F)16 14=(E)16
Step 2 15 /16 0 15=(F)16
Converted whole No. (FE)16
Part 2 converting fractional part
Step Multiply by Product Whole No.
2
Step 1 16x 0.655 10.48 10=(A)16
Step 2 16x 0.48 7.68 7
Step 3 16x 0.68 10.88 10=(A)16
7 Introduction to comp. application
Converted fractional No. (.A7A)16

Part 3 combine the two components and gives (254.655)10 = (FE.A7A)16

Ex 2 Convert 3010 to base 16 (hex) Ex 3 Convert (16)10 to base 16


3010=(1E)16 1610=(10)16

Conversion from base M (other than base 10) to base 10 (decimal)


To convert a number X consists of digits X1 X2 X3 …Xn in base M to decimal; simply expand the
number with base M. That is
n-1 n-2 n-3 n-i 1 0
(X1X2X3…Xn) m =X1*m +X2*m +X3*m +...+ Xi*m +… Xn-1m +Xn*m =Y10
Step 1 − Determine the column (positional) value of each digit (this depends on the position of the digit
and the base of the number system).
Step 2 − multiply the obtained column values (in Step 1) by the digits in the corresponding columns.
Step 3 − Sum the products calculated in Step 2. The total is the equivalent value in decimal.
3.6.1.4. Binary to Decimal
The same process is followed with the exception that the base in the summation is changed to 2.
Converting from binary to decimal can be accomplished quickly in your head due to the fact that the bit
values in the products are either 1 or 0. That means any bit that is a 0 has no impact on the outcome and
any bit that is a 1 simply yields the weight of its position.
Example 1: - Binary Number: 111012 and Calculating Decimal Equivalent −
Step Binary Number Decimal Number
Step 1 111012 ((1 x 2 ) + (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20))10
4

Step 2 111012 (16 + 8 + 4 + 0 + 1)10


Step 3 111012 2910

Binary Number: 111012 = Decimal Number: 2910

Example 2:-The binary number 1101.11 may be Example 3:- Convert (11001.0101)2 to decimal
expanded as 11001 = 1x24 + 1x23 +0x22+0x21+1x20=
3 2 1 0 -1 -2
(1101.11)2 =1*2 +1*2 +0*2 +1*2 +1*2 +1*2 16+8+1= 25 (integer part)
0101=0x2-1+1x2-2+0x2-3+1x2-4=
= (1*8)+(1*4)+(0*2)+(1*1) +(1*0.5)+(1*0.25)
0+¼+0+1/16 = 0.3125 (fraction part)
= 8+4+0+1 +0.5+0.25
11001.0101 = (25.3125)10
= (13.75)10

Exercise :- convert (101.11)2 to decimal Ans=(5.75)10


Exercise:- Convert (1000.1)2 to decimal. Ans=(?)10

8 Introduction to comp. application


3.6.1.5. Octal to Decimal
When converting from octal to decimal, the same process is followed with the exception that the base
in the weight is changed to 8.

Ex 2. Convert (234)8 to decimal Ex 3. Convert (101)8 to decimal


Ans. = (156)10 Ans. =(65)10

3.6.1.6. Hexadecimal to Decimal


The same process is followed with the exception that the base is changed to 16. When performing the
conversion, the decimal equivalents of the numerals A–F need to be used.
Example:- convert (1AB.EF)16 to decimal

9 Introduction to comp. application


Example:- Convert (A1B) 16 to decimal Convert (101)16 to decimal
Ans. = (2587)10 Ans. =(257)10

3.6.2. Conversion from binary (base2) to Octal (base 8) or hexadecimal (base16) and vice versa
 Shortcut Method ─ Binary to Octal
Step 1 −To convert a number in binary to octal divide or group the binary digits into groups of three
(starting from the last digit (right), if there are no enough digits add zeros to the front end (left) and
find the corresponding decimal of each group).
Step 2 −Convert each group of three binary digits to one octal digit.
Example: - Binary Number: 101012 and calculating Octal Equivalent −
Step Binary Number Octal Number
Step 1 101012 010 101
Step 2 101012 (2)8 (5)8
Step 3 101012 (25)8

Binary Number: 101012 = Octal Number: 258

Eg. 1.Convert binary no. 1001001 to octal 2. Convert 101101001 to octal


Solution. 1001001=001,001,001 Solution. 101101001 =101,101,001
= 1118 =5518

 Shortcut Method ─ Binary to Hexadecimal


Step 1 − To convert binary to hexadecimal, follow the same procedure to the above but divide the
binary digits into groups of four (starting from the right).
Step 2 − Convert each group of four binary digits to one hexadecimal symbol.
Example: - Binary Number: 101012
Calculating hexadecimal Equivalent −
Step Binary Number Hexadecimal Number
Step 1 101012 0001 0101
Step 2 101012 110 510
Step 3 101012 1516

Binary Number: 101012 = Hexadecimal Number: 1516

Eg. 1.Convert 111100100 to hexadecimal 2. Convert 111001111 to Hexadecimal


n
Sol . 111100100 =0001 1110 0100 Soln. 111001111 =0001 1100 1111
= 1 14 4 = 1 12 15
=1 E 4 =1 B F

10 Introduction to comp. application


= 1E416 = (1BF) 16

 Shortcut Method ─ Octal to Binary


Step 1 – To convert from Octal to binary, convert each octal digit to its equivalent 3 bit binary starting
from right.
Step 2- Convert each octal digit to a 3-digit binary number (the octal digits may be treated as decimal
for this conversion).
Step 3 − Combine all the resulting binary groups (of 3 digits each) into a single binary number.
Example 1: - Octal Number: 258
Calculating Binary Equivalent −
Step Octal Number Binary Number
Step 1 258 210 510
Step 2 258 0102 1012
Step 3 258 0101012
Octal Number: 258 = Binary Number: 101012
Example 2: Convert (675) eight to binary
675eight =110 111 101
=110111101two

 Shortcut Method - Hexadecimal to Binary


Step 1 −To convert from Hexadecimal to binary convert each hexadecimal digit to its equivalent 4-bit binary
starting from right.
Step 2 − Combine all the resulting binary groups (of 4 digits each) into a single binary number.
Example:-Hexadecimal Number: 1516 Calculating Binary Equivalent −
Step Hexadecimal Number Binary Number
Step 1 1516 110 510
Step 2 1516 00012 01012
Step 3 1516 000101012
Hexadecimal Number: 1516 = Binary Number: 101012

Example.1. Convert 23416 to binary 3. Convert 2AC to binary


216 =00102 solun. 2AC16 =0010 1010 1100
316= 00112 =10101011002
416=01002
23416 = (1000110100)2

3.6.3. Conversion from Octal to hexadecimal and vice versa


To convert from Octal to hexadecimal, first we have to convert to binary and the binary to hexadecimal.
To convert from hexadecimal to Octal, first we have to convert to binary and then the binary to Octal.

11 Introduction to comp. application


Example. 1. Convert 2358 to hexadecimal 2. Convert 1A to Octal
2358=010 011 101 1A= 0001 1010
= 000 011 010
=0000 1001 1101
= 0 3 2
= 0 9 13
=328
=9D16

 Base „n‟ number has „n‟ possible digits and the digits are 0 to n-1
Notice: before you start converting a number to a specified base, check whether the given number is
legal one
e.g. (230)2 is illegal and same is true for (98)8
Exercise (Check whether the answer is correct or not)
A. decimal to binary conversion
1. (35)10= (?)2 Ans. (1000011)2
2. (75.68)10= (?)2 Ans. (1001011.10101)2
3. (101.07)10= (?)2 Ans. (1100101.00010…)2
4. (15)10= (?)2 Ans.(1111)2
5. (65.2)10= (?)2 Ans. (1000001.0011...)2
6. (100.011)10= (?)2 Ans.(1100100.00000001…)2
7. (59.99)10= (?)2 Ans.(111011.111)2
8. (40.34)2= (?)2 Ans.(101000.0101)2
B. binary to decimal conversion
9. (110010)2= (?)10 Ans.(50)10
10. (11101101.10101)2= (?)10 Ans.(237.65625)10
11. (11)2= (?)10 Ans.(3)10
12. (1111)2= (?)10 Ans. (15)10

3.7. Binary Arithmetic


Binary numbers can be added, subtracted, multiplied and divided like natural numbers-decimal
numbers in which everybody uses them for day-to-day activities. Let‟s see how binary arithmetic is
performed.

3.7.1. Binary Addition


Rules
0+1=1
1+1=0 with carry 1 to the next digit
12 Introduction to comp. application
1+1+1=1 with carry 1 to the next digit
1+1+1+1=0 with carry 2 to the next digit
E.g. Add (10111)2 and (110101)2
Solution
110101
+10111
Ans: 1001100

3.7.2. Binary Subtraction: - If you must subtract a one from a zero, you need to
“borrow” from the left, just as in decimal subtraction.
Rules
1-1=0
1-0=1
0-1=1 borrows 1 from the highest digit
E.g. Subtract (10101)2 from (101110)2
Solution
101110
-10101
11001
See the following example:

** Binary subtraction can be also done using complements.


E.g. (1110-10101)2= (?)2
Solution
Rule: A-B=A+ (-B), where B is 2‟s complement
2‟s complement=1‟s complement + 1
(10101)2 1‟s complement = (01010)2 and its 2‟s complement= (01011)2.
Then, apply the rule i.e. (1110-01011)2= (1110-1011)2= (11)2

13 Introduction to comp. application


3.7.3. Binary Multiplication
Rules
1x1=1
0x1=0
E.g. 1. Multiply (1111)2 by (111)2 E.g. 2. (1011.01)2 x (10.1)2
Solution Solution
1111 1011.01
X 111 X 10.1
1111 101101
1111 000000
1111 101101
(1101001)2 (11100.001)2

Assignment:
1. convert 192 to base 2
2. convert 192 to base 16
3. convert 192 to base 8
4. convert (100010101110.11011101)2 to decimal
5. convert (100010101110.11011101)2 to octal
6. convert (100010101110.11011101)2 to hexadecimal
7. convert (ABEBE)16 to decimal
8. convert (ABEBE)16 to binary
9. convert (ABEBE)16 to octal
10. convert( 256)2 to octal
11. let A= 14, B= 9 find a) A-B b) B-A c)-A-B using ones and twos complements in 5 bits

14 Introduction to comp. application

You might also like