data representation in computers student :ahmed alsaqqa 120060521 mis: rasha ragheb atallah

45
Data Data Representation Representation in Computers in Computers Student :Ahmed Alsaqqa Student :Ahmed Alsaqqa 120060521 120060521 MIS: MIS: Rasha Ragheb Atallah Rasha Ragheb Atallah

Upload: brendan-ward

Post on 24-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Data Data Representation in Representation in

ComputersComputers

Student :Ahmed AlsaqqaStudent :Ahmed Alsaqqa

120060521120060521

MIS: MIS: Rasha Ragheb AtallahRasha Ragheb Atallah

Page 2: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Session ObjectivesSession Objectives

Describe what a Number system isDescribe what a Number system is Explain the decimal, octal and Explain the decimal, octal and

hexadecimal number systemshexadecimal number systems Convert a number from one number Convert a number from one number

system to anothersystem to another Practice binary arithmeticPractice binary arithmetic List the various standard codes used to List the various standard codes used to

represent the unit of informationrepresent the unit of information ASCIIASCII EBCDICEBCDIC

Page 3: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Session Objectives (Contd.)Session Objectives (Contd.)

Explain Data RepresentationExplain Data Representation Explain Data StorageExplain Data Storage Explain Packed DecimalExplain Packed Decimal Binary Arithmetic Calculation Binary Arithmetic Calculation Explain CPU and its speedExplain CPU and its speed

Page 4: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Number Number systemssystems

The additive approach - Number earlier consisted of symbols e.g. Roman number system - I for 1, II for 2, III for 3 etc.

Positional numbering - Symbols represent different values depending on the position they occupy e.g. the Decimal system

Page 5: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Decimal Number Decimal Number SystemSystem

In the decimal number system In the decimal number system the successive position to the the successive position to the left of the decimal point left of the decimal point represent units, tens, represent units, tens, hundreds, thousands etc. hundreds, thousands etc.

(3 * 100) + (6*10) + (5*1) = (3 * 100) + (6*10) + (5*1) = 365365

The position of the number The position of the number affects its value. affects its value.

These kind of number systems These kind of number systems therefore are called positional therefore are called positional number system. number system.

Base

Position number

(6*10)

Page 6: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Decimal Number System Decimal Number System (Contd.)(Contd.) The value of each digit in the

number system is determined by: a) The digit itself

b) The position of the digit in the number

c) The base/radix of the system

Page 7: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Binary Number Binary Number SystemSystem

The binary number system has a base of The binary number system has a base of two and symbols used are 0 and 1.two and symbols used are 0 and 1.

In this number system, as we move to In this number system, as we move to the left, the value of the digit will be two the left, the value of the digit will be two times greater than its predecessor times greater than its predecessor because the base is two. because the base is two.

Thus the value of the places are :Thus the value of the places are : 64 64 32 32 16 16 8 8 4 4 2 2 1 1

0001111001010111

Least Significant bit Most Significant bit

Binary Number

Page 8: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Octal number Octal number systemssystems

Binary OctalBinary Octal 000000 00 001001 11 010010 22 011011 33 100100 44 101101 55 110110 66 111111 77

Uses a base of Uses a base of 88

Values increase Values increase

from right to from right to left 1, 8, 64, left 1, 8, 64, 512 ... 512 ...

Page 9: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Octal Number Octal Number SystemSystem

The octal system has the base of 8. The octal system has the base of 8. The value increase from right to left The value increase from right to left as 1, 8, 64, 512, 4096. as 1, 8, 64, 512, 4096.

The decimal value of an octal The decimal value of an octal number 1204 can be computed as : number 1204 can be computed as :

12041204) = ) = 11 * * 512512) + () + (22 * * 6464) + () + (00 * * 88) + () + (44 * * 11 ( ( = = 512512 + + 128128 + + 00 + + 44   = = 644644

Page 10: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Octal Number Octal Number SystemSystem

BinaryBinaryOctalOctal  00000000001001110100102201101133

100100                          4410110155

110110                          66111111                          77

To convert a number from binary to octal and vice versa, the following table must be kept in mind: 

Page 11: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Hexadecimal Number Hexadecimal Number SystemsSystems

Hexadecimal Decimal 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 A 10 B 11 C 12 D 13 E 14 F 15

Page 12: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Hex. Number Hex. Number Systems(Contd.)Systems(Contd.) Uses a base of 16

The 16 symbols required for the hexadecimal number system obtained by using the alphabets A, B, C, D, E and F Converting hexadecimal to decimal decimal equivalent of a hexadecimal number A0119 (10 * 65,536)+(0 * 4,096)+(1 * 256)+ ( 1 * 16) + ( 9 * 1) = 6,55,360 + 0 + 256 + 16 + 9 = 6, 55, 641

Page 13: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Converting binary numbers to decimal value <64 <32 <16 <8 <4 <2 <1

The decimal equivalent of 110100 is

= (1 * 32 ) + (1 * 16) + (0 * 8) + ( 1 * 4) + ( 0 * 2) + (0 * 1)

= 32 + 16 + 0 + 4 + 0 + 0 = 52

Binary to Decimal Binary to Decimal ConversionConversion

Page 14: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Divide the decimal number by the

base of the required number system Note the remainder in one column

and divide the quotient again with the base Keep repeating this process until quotient is

reduced to a zero Reading remainders in the reverse

order gives the binary equivalent

Decimal to Binary Decimal to Binary ConversionConversion

Page 15: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

E.g. Converting the decimal number 52 to its binary equivalent. Remainder 2 |__52 2 |__26 | 0 2 |__13 | 0 2 |__06 | 1 2 |__03 | 0 2 |__01 | 1 2 |__00 | 1Thus the binary equivalent of the decimal number 52 is 110100

Decimal to Binary Decimal to Binary ConversionConversion

Page 16: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Binary to Binary to HexadecimalHexadecimal

Each hexadecimal digit is represented by 4 binary digits. Binary Hexadecimal 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F

Page 17: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Binary to Hexadecimal Binary to Hexadecimal (Contd.)(Contd.)Split the quantity into groups of four

outwards from right to leftEach group of four is directly converted into its hexadecimal equivalentAdd zeros to the left of the number if necessaryE.g. Binary 10101011000010

Hexadecimal Equivalent 0010 1010 1100 0010 2 A C 2

Page 18: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Hexadecimal to Hexadecimal to BinaryBinary Write binary equivalent of each

hexadecimal digit in groups of four E.g. hexadecimal 191A412C 0001 1001 0001 1010 0100 0001 0010 1100 Thus the required binary number can be written as :

11001000110100100000100101100

The leading zeroes are omitted

Page 19: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Converting from Binary to Converting from Binary to OctalOctal

The binary number must be The binary number must be divided into groups of three divided into groups of three from the octal point- to the from the octal point- to the right in case of the fractional right in case of the fractional portion and to the left in case portion and to the left in case of the integer portion. of the integer portion.

Each group can then be Each group can then be replaced with their octal replaced with their octal equivalent. equivalent.

We may add zero to the left We may add zero to the left of the number if required.of the number if required.

For example :

Binary 101010101010100

101 010 101 010 100 5 2 5 2 4

52524 is the octal equivalent of the given binary number.

Page 20: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Converting from Octal to Converting from Octal to BinaryBinary

For example :For example :

      6         56         5

110 101110 101

   Similarly the binary Similarly the binary

equivalent of the octal equivalent of the octal number 65 is 110101.number 65 is 110101.

Each octal digit is replaced with the appropriate ‘triple’ of binary digits.

Page 21: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Binary ConceptsBinary Concepts-- OFF

-- ON

DATA(in binary Digits)

Page 22: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Data Data RepresentationRepresentation

000111 000111010101 011101000110100101010010 01010 1010101 01001 10010001 001001 0011110 0110100 101010 10010101 101010 1010000

Main(){ printf(“ Hello”);

printf(“We are enjoying a world of alphabetical coding”);

}

Page 23: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Data Data RepresentationRepresentation Digital computers use binary code to

represent characters. Binary code is made up of binary digits or bits. A string of "0s" and "1s" is used to represent characters. Byte is a sequence of 8 bits. Most computers have words that consist of 8 or 16 bits. In large computers the number of bits per word could be 16 or 32 bits.

Page 24: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Data representation Data representation (Contd.)(Contd.)When data is keyed in, each keystroke

is converted to a binary character code and transmitted to the computer

Each character to the printer, screen, disk is communicated in binary code.

While displaying or printing, the character is converted back to human readable form

Page 25: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Data is stored and processed in computers in the binary form. These symbols 0 and 1, are called bits 2 bits give four unique combinations i.e. 00, 01, 10 , 11. A string of 8 bits is called a byte Words are stored one character/byte.

Data Data StorageStorage

Page 26: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

During calculation the decimal During calculation the decimal number is converted to its number is converted to its binary equivalent.binary equivalent.

After calculation the result is After calculation the result is converted back to its decimal converted back to its decimal equivalent.equivalent.

Data Storage (Contd.)Data Storage (Contd.)

Page 27: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

The Packed The Packed DecimalDecimal

Packed decimal - data is stored in

a half- way house between pure binary

and one byte per digit Four bits are required to store all 10

symbols that constitute the decimal

number system One byte would store the representation

of two decimal digits

Page 28: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

e.g. The number 34 would be stored in character form as: Byte 1 Byte 2 00000011 00000100

3 4 Using packed decimal the same number would be stored as : Byte 0011 0100 3 4

The Packed Decimal The Packed Decimal (Contd.)(Contd.)

Page 29: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Binary Arithmetic AdditionBinary Arithmetic Addition The following rules of binary addition are to be remembered: 0 + 0 = 0 0 + 1 = 1 = 1 + 0 1 + 1 = 0 carry 1 to the next column to

the left 1 + 1 + 1 = 1 carry 1 to the next columne.g. Carry 1 1 1 1

11011 + 111 100010

Page 30: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Complementary Complementary SubtractionSubtractionThree steps to perform subtraction :

Find the complement of the number you are subtractingTo the complement of the number add the number we are subtracting from If there is a carry of 1 add the carry to the result of the addition

else re-complement the sum and attach a negative sign

Page 31: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

To find the complement of a binary number invert all the bits

e.g. Number Complement 10001101 01110010 00101010 11010101

Complementary Subtraction Complementary Subtraction (Contd.)(Contd.)

Page 32: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Example of subtractionExample of subtraction: :

e.g.1e.g.1 10101011010101 - - 10011001001100

Step 1. Find the complement ofStep 1. Find the complement of 10011001001100

It isIt is 01100110110011

Complementary Subtraction Complementary Subtraction (Contd.)(Contd.)

Page 33: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Step 2. Add the number you are subtracting from carry 1110111 1010101 + 0110011 0001000Since there is a carry of 1, Add the carry 0001000

+ _______ 1 0001001

Complementary Subtraction Complementary Subtraction (Contd.)(Contd.)

Page 34: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

e.g.2 101100 - 11100101Step 1. Complement of 11100101 is 00011010Step 2.Carry 0111 00101100 +00011010 01000110Step 3. Since there is no carry we re-complement the result and add a negative signThus the answer is -10111001

Complementary Subtraction Complementary Subtraction (Contd.)(Contd.)

Page 35: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

MultiplicationMultiplication

Rules for Rules for MultiplicationMultiplication::

00 x 0 = 0x 0 = 0 00 x 1 = 0x 1 = 0 11 x 0 = 0x 0 = 0 11 x 1 = 1x 1 = 1

E.g.. 10101 * 11001E.g.. 10101 * 11001

1010110101 x11001x11001

------- ------- 1010110101

0000000000 0000000000

1010110101 1010110101

----------- ----------- 10000011011000001101

Page 36: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

DivisiDivisionon1. Start from the left of the dividend

2. Perform subtraction i.e. divisor should be subtracted from the dividend a) if subtraction is possible put 1 in the quotient and subtract the divisor from digits of the dividend else put 0 in the quotient b) bring down the next digit to the

right of the remainder 3. Do step 2 till no more digits remain in

the dividend

Page 37: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

DivisiDivisiononThe complete table for binary division is:

0/1 = 01/1 = 1

For example:

100001 / 110Then, 0101 (Quotient)

________ 110100001 (Dividend)(Divisor)110 --- Step 1 1000 --- Step 2b 110 --- Step 2a 100 --- Step 2b 110 --- Step 2a 1001 --- Step 2b 110 --- Step 2a 11 (Remainder)

Page 38: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

Unit of Unit of InformationInformation Most computers use a coded version of true

binary numbers to represent letters, special symbols, decimal numbers etc.

7 digits are required to uniquely represent all 128 characters

Standardised coding to enable transfer of data between computers

Page 39: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

ASCASCIIIICommon standard is the American Standard

Code for Information Interchange (ASCII)ASCII uses 7 bits per character possible to provide 128 different arrangementsSeparate Codes are used to convey - end of file, end of page etc. to the computerThese codes are called non-printable control characters ASCII code is used to represent data internally in personal computers

Page 40: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

EBCDIEBCDICC

Extended Binary Coded Decimal Interchange Code ( EBCDIC) EBCDIC uses 8 bits per character Thus 256 characters can be represented using EBCDIC The EBCDIC code is used in IBM mainframe models and other similar machines Electronic Circuits available to transform characters from ASCII to EBCDIC and vice- versa One can achieve the same results using a computer program

Page 41: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

An insight into CPUAn insight into CPU

CPU also referred, as Microprocessor CPU also referred, as Microprocessor is actually the brain of a computer. is actually the brain of a computer.

There are lot of chips on the There are lot of chips on the motherboard and they all kind of look motherboard and they all kind of look alike. alike.

There are several companies who There are several companies who manufacture microprocessor chips : manufacture microprocessor chips : Advanced Micro Devices (AMD), Advanced Micro Devices (AMD), Cyrix, Intel …Cyrix, Intel …

Page 42: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

CPU PropertiesCPU Properties

The following are some of CPUs propertiesThe following are some of CPUs properties::

Page 43: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

What is meant by CPU What is meant by CPU speedspeed ? ?

Every computer contains an internal Every computer contains an internal clock that regulates the rate at which clock that regulates the rate at which each instruction is executed. each instruction is executed.

The clock speed is measured in terms of The clock speed is measured in terms of MegaHertz (MHz). MegaHertz (MHz).

1 Mhz is equal to 1 million cycles per 1 Mhz is equal to 1 million cycles per second. Hence a computer with 120 second. Hence a computer with 120 MHz speed means 120 million cycles per MHz speed means 120 million cycles per second. second.

It must be noted that a faster CPU with It must be noted that a faster CPU with less hard disk space would result into a less hard disk space would result into a mediocre machine performance.mediocre machine performance.

Page 44: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

What if I increase the speed of What if I increase the speed of clockclock??

Running a microprocessor much faster Running a microprocessor much faster than the speed for which it has been than the speed for which it has been tested and approved is also called as tested and approved is also called as “Overclocking”. “Overclocking”.

In many cases you can force your CPU In many cases you can force your CPU to run faster by setting the jumper on to run faster by setting the jumper on the motherboard. But it may cause the motherboard. But it may cause overheating.overheating.

Normally, running a CPU too fast will Normally, running a CPU too fast will not damage the chip but the computer not damage the chip but the computer would not function properly.would not function properly.

Page 45: Data Representation in Computers Student :Ahmed Alsaqqa 120060521 MIS: Rasha Ragheb Atallah

What is meant by Word Size What is meant by Word Size and how is it related with and how is it related with

speedspeed ? ? Every computer has internal work areas, kind Every computer has internal work areas, kind

of little workbenches. These workbenches are of little workbenches. These workbenches are called as registers. called as registers.

Registers are special high-speed storage area Registers are special high-speed storage area within the CPU. All data must be represented within the CPU. All data must be represented in the register before it can be processed. in the register before it can be processed.

The number of the registers a CPU has and the The number of the registers a CPU has and the size of each (in terms of bits) determine the size of each (in terms of bits) determine the speed and performance of the CPU. speed and performance of the CPU.

The largest number a computer can process in The largest number a computer can process in one operation is determined by size of a word. one operation is determined by size of a word.