Sunteți pe pagina 1din 13

Chapter Three

DATA REPRESENTATION INSIDE A 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). So 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: no-positional and positional.
1. No-positional number system
It is familiar with Roman Notation System. In this system, each system 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 a traditional additive approaches.
2. Positional number 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.
1. Binary number system
- The most popular form which is understood by the computer.
- Its radix is 2.
- It uses two digits i.e. 0 & 1.
- Sometimes it is also called base-two system.

Page 1
Chapter Three
Value 128 64 32 16 8 4 2 1

Weight 27 26 25 24 23 22 21 20

Position VIII VII VI V IV III II I


e.g. (110101)2
2. Octal Number System
It was once a popular number base, especially in the digital equipment like old computer systems. It
is rarely used today.
- It was developed to provide a shorthand way to deal with the long strings of 1s and 0s created
in the binary system.
- The radix of octal is 8.
- It uses eight digits i.e. 1, 2, 3, 4, 5, 6, and 7. As 2 3 =8, an octal number is represented by a set
of 3 bits. e.g. (5)8= (101)2
- The binary representation system of an octal number is also called Binary Coded Octal
Number.
Value 2097152 262144 32768 4096 512 64 8 1
Weight 87 86 85 84 83 82 81 80
Position VIII VII VI V IV III II I
3. Decimal Number System
- It is the most popular form of numbering system which is used by human being.
- Its radix is 10.
- It is also called base-ten system or natural number system.
- It includes the numbers from 0-9.
Value 10000000 1000000 100000 10000 1000 100 10 1
Weight 107 106 105 104 103 102 101 100
Position VIII VII VI V IV III II I
4. Hexadecimal Number System
A big problem with the binary system is verbosity. To represent the value 202 requires eight binary
digits. The decimal version requires only three decimal digits and, thus, represents numbers much more
compactly than does the binary numbering system. When dealing with large values, binary numbers
quickly become too unwieldy. The hexadecimal solves these problems. Hexadecimal numbers offers the
two features:
- hex numbers are very compact
- It is easy to convert from hex to binary and binary to hex.

Page 2
Chapter Three
The hexadecimal system is based on the binary system using a Nibble or 4 bit boundary. The
hexadecimal number system
- uses base 16
- Includes 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.
Value 268435456 16777216 1048576 65536 4096 256 16 1
Weight 167 166 165 164 163 162 161 160
Position VIII VII VI V IV III II I

CONVERSION SYSTEM
A brief summary on conversion from one base to another base
No From base To base Method
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.
1 10 16 Go from 10216 or divide the decimal number by 16 until the
0 quotient becomes zero.
1 8 16 Go from 8216 (preferable and simplest method) but you can go
1 from 81016
1 16 8 Go from 1628 (preferable and simplest method) but you can go
2 from 16108

Ex1: Convert (1001001)2 to decimal


1x26+0x25+0x24+1x23+0x22+0x21+1x20
Ans. = (73)10
Convert (11001.0101)2 to decimal

Page 3
Chapter Three
4 3 2 1 0
11001 = 1x2 + 1x2 +0x2 +0x2 +1x2 =
16+8+1= 25 (integer part)
0101=0x2-1+1x2-2+0x2-3+1x2-4=
0+¼+0+1/16 = 0.3125 (fraction part)
11001.0101 = (25.3125)10
Convert (1000.1)2 to decimal
(1000)2= (1+23 +0+0+0) 10= (8)10 (integer part)
0.1= 1x2-1=½ = (0.5) 10 (fractional part)
(1000.1)2 = (8.5)10 (after combination of both results of integral & fractional part)
Ex 2. Convert 5610 to binary
(56)10 = (111000)2
Ex 3. Convert (1001001)2 to octal
1001001=001 001 001
= (111)8
Convert 101101001 to octal
101101001=101 101 001
5 5 1
= (551)8
Exercise: - Covert (1010.0111)2 to its equivalent octal number
Ex 4. Convert (675)8 to binary
68 = (110) 2 78= (111) 2 58= (101) 2
Therefore, (675)8 = (110111101)2
Convert 2318 to binary
2318 = (010 011 001) 2
=(10011001)2
Ex 5. Convert 111100100 to hexadecimal

1111001002= (0001 1110 0100) 2


= (1 E 4) 16
= (1E4)16
Exercise: - Covert (1110101.10111)2 to its equivalent hexadecimal
Ex 6. Convert 23416 to binary
216 =00102
316= 00112

Page 4
Chapter Three
416=01002
23416 = (1000110100)2
Convert 2AC16 to binary
2AC16 = (0010 1010 1100) 2
= (1010101100)2
Ex 7. Convert (234)8 to decimal
Ans. = (156)10
Convert (101)8 to decimal
Ans. =(65)10
Ex 8. Convert 7810 to base 8 (Octal)
7810=1168
Ex 9. Convert (A1B) 16 to decimal
Ans. = (2587)10
Convert (101)16 to decimal
Ans. =(257)10
Ex 10. Convert 3010 to base 16 (hex-decimal)
3010=(1E)16
Convert (16)10 to base 16 (hexadecimal)
1610=(10)16
Ex.11. Convert 2358 to hexadecimal
2388=010 011 101
=0000 1001 1101
=0 9 13=D
=(9D)16
Ex.12. Convert 1A16 to Octal
116=00012
A16=10102
= (000 011 010) 2
(0 3 2)8
=(32)8

Exercise (Check whether the answer is correct or not)


A. decimal to binary conversion (double-dabble method)
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

Page 5
Chapter Three
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
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.

1. Binary addition
Rules
0+1=1
1+1=0 with carry 1 to the next digit
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
1001100

2. Binary 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

Page 6
Chapter Three
** 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 complemenent = (01010)2 and its 2’s complemenent= (01011)2.
Then, apply the rule i.e. (1110 + 01011)2= (1110-1011)2= (11001)2

3. Binary multiplication
Rules
1x1=1
0x1=0
E.g. 1. Multiply (1111)2 by (111)2
Solution
1111
X 111
1111
1111
1111
(1101001)2

E.g.2. (1011.01)2 x (10.1)2


Solution
1011.01
X 10.1
101101
000000
101101
(11100.001)2
4. Binary division

Page 7
Chapter Three
Rules
This rule works for a number in which the remainder becomes zero. It may work for non-zero
remainder numbers with some modifications.
a) Divide the dividend by the divisor until the remainder becomes zero or less than the divisor
(impossible to be divided).
b) When you take two or three etc numbers of a dividend to add on the remainder part, you have
to add one zero (0) or two (00) etc on the quotient respectively.
c) When you divide a number having fractional part, don’t worry about the fraction. Divide the
number as it is an integer number. But after you complete the division, count the number of fractional
digits from left to right to both the dividend (D) and divisor (Df). Then the number of fractional parts of
the quotient (Qf) from left to right is equal to the difference between of D & Df.
d) Checking the result
Dividend=quotient * divisor + remainder
E.g.1. Divide (100001)2 by (11)2
Solution

Checking: 100001=11x1011 + 0
100001=100001
E.g. 2. Divide (1011.01)2 by (10.1)2
Solution

Checking
1011.01=100.1x10.1 + 0
1011.01=1011.01
Note: If the difference between D & Df is negative, add zero(s) as many as the number of the
difference on the right side of the quotient. Let’s see it with an example.

Page 8
Chapter Three
E.g.3. Divide (101101)2 by (10.1)2
Solution

CODING METHODS
- It is possible to represent any of the character in our language in a way as a series of
electrical switches in arranged manner.
- These switch arrangements can therefore be coded as a series of an equivalent arrangements
of bits.
- There are different coding systems that convert one or more character sets into computer
codes. Some of them are the followings :
BCD (6-bits)
- Stands for Binary Coded Decimal
- It uses 6-bits to code a Character
BCD coding Examples

Character Zone digits


A 11 0001
Q 10 1000
8 00 1000
9 00 1001

EBCDIC
- Pronounced as “Eb-see-dick” and stands for Extended Binary Coded Decimal Interchange
Code.

Page 9
Chapter Three
- It is an 8-bit coding scheme; (00000000 – 11111111)
- It accommodates to code 28 or 256 different characters
- It is a standard coding scheme for the large computers.
Coding Examples

EBCDIC
Character Zone Digit
a 1000 0001
b 1000 0010
A 1100 0001
B 1100 0010
0 1111 0000
9 1111 1001

ASCII-7
- ASCII stands for American Standard Code for Information Interchange
- Used widely before the introduction of ASCII-8 (the Extended ASCII)
- Uses 7 bits to represent a character;
- With the seven bits, 27 ( or 128) different characters can be coded (0000000-1111111)
- It has a zone and digit bits positions
ASCII-7 coding examples:

Character Zone digit


$ 010 0100
% 010 0101
A 100 0001
a 110 0001
b 110 0010
The ASCII System
- Also referred as ASCII-8 or Extended ASCII
- It is the most widely used type of coding scheme for Micro Computer system
- ASCII uses 8-bits to represent alphanumeric characters (letters, digits and special symbols).
- With the 8-bits, ASCII can represent 28 or 256 different characters (00000000-11111111).

Page 10
Chapter Three
Coding Examples
Binary representation in ASCII
Character Zone Digit
a 0110 0001
b 0110 0010
A 0100 0001
B 0100 0010
? 0011 1111
+ 0010 1011
1 0011 0001
2 0011 0010
3 0011 0011

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, nibble, byte and word.
- These units are the boundaries of binary number system.
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.
Nibble
- Nibble is a collection of bits on a 4-bit boundary.
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.

Page 11
Chapter Three
- The commonly used byte contains 8 bits; or also contains exactly two nibbles.
- 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 either 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.
- If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where
KB stands for kilobyte.
Key: 1 Kilobyte (1KB) is 210 or 1024 bytes
1 Megabyte (MB) is 220 bytes or 210 kilobytes
1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210 megabytes

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.. So
we may have double word, triple and more.
- We say that a computer is an 8-bit, a 16 bit, a 32 bit or a 64 bit computer to indicate that the
amount of data it can process at a time. Word length is usually given in bits. A word also contains either
16 bits or two bytes.
- The large the word length a computer has the more powerful and faster it is.

Page 12
Chapter Three

Page 13

S-ar putea să vă placă și