Computer Fundamentals PDF

Document Details

Uploaded by Deleted User

Pradeep K. Sinha & Priti Sinha

Tags

computer fundamentals computer science introduction to computers computer generations

Summary

This document provides an introduction to computer fundamentals, covering computer characteristics, data processing, and computer generations. It explores the evolution of computers from early mechanical models to modern integrated circuits, emphasizing key hardware and software technologies throughout.

Full Transcript

CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeepep KK.. SSiinhanha && PPrriititi SSiinhanha Ref Page Chapter 1: Introduction to Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapt...

CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeepep KK.. SSiinhanha && PPrriititi SSiinhanha Ref Page Chapter 1: Introduction to Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapter you will learn about:  Computer  Data processing  Characteristic features of computers  Computers’ evolution to their present form  Computer generations  Characteristic features of each computer generation Ref Page 01 Chapter 1: Introduction to Computers Slide 2/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Compute r  The word computer comes from the word “compute”, which means, “to calculate”  Thereby, a computer is an electronic device that can perform arithmetic operations at high speed  A computer is also called a data processor because it can store, process, and retrieve data whenever desired Ref Page 01 Chapter 1: Introduction to Computers Slide 3/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Data Processing The activity of processing data using a computer is called data processing Data Capture Data Manipulate Data Output Results Information Data is raw material used as input and information is processed data obtained as output of data processing Ref Page 01 Chapter 1: Introduction to Computers Slide 4/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Characteristics of Computers 1) Automatic: Given a job, computer can work on it automatically without human interventions 2) Speed: Computer can perform data processing jobs very fast, usually measured in microseconds (10-6), nanoseconds (10-9), and picoseconds (10-12) 3) Accuracy: Accuracy of a computer is consistently high and the degree of its accuracy depends upon its design. Computer errors caused due to incorrect input data or unreliable programs are often referred to as Garbage- In-Garbage-Out (GIGO) (Continued on next slide) Ref Page 01 Chapter 1: Introduction to Computers Slide 5/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Characteristics of Computers (Continued from previous slide..) 4) Diligence: Computer is free from monotony, tiredness, and lack of concentration. It can continuously work for hours without creating any error and without grumbling 5) Versatility: Computer is capable of performing almost any task, if the task can be reduced to a finite series of logical steps 6) Power of Remembering: Computer can store recall any and amount of information because of its secondary storage capability. It forgets or looses certain information only when it is asked to do so (Continued on next slide) Ref Page 01 Chapter 1: Introduction to Computers Slide 6/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Characteristics of Computers (Continued from previous slide..) 7) No I.Q.: A computer does only what it is programmed to do. It cannot take its own decision in this regard 8) No Feelings: Computers are devoid of emotions. Their judgement is based on the instructions given to them in the form of programs that are written by us (human beings) (Continued on next slide) Ref Page 01 Chapter 1: Introduction to Computers Slide 7/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Evolution of Computers  Blaise Pascal invented the first mechanical adding machine in 1642  Baron Gottfried Wilhelm von Leibniz invented the first calculator for multiplication in 1671  Keyboard machines originated in the United States around 1880  Around 1880, Herman Hollerith came up with the concept of punched cards that were extensively used as input media until late 1970s Ref Page 01 Chapter 1: Introduction to Computers Slide 8/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Evolution of Computers (Continued from previous slide..)  Charles Babbage is considered to be the father of modern digital computers  He designed “Difference Engine” in 1822  He designed a fully automatic analytical engine in 1842 for performing basic arithmetic functions  His efforts established a number of principles that are fundamental to the design of any digital computer (Continued on next slide) Ref Page 01 Chapter 1: Introduction to Computers Slide 9/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Some Well Known Early Computers  The Mark I Computer (1937-44)  The Atanasoff-Berry Computer (1939-42)  The ENIAC (1943-46)  The EDVAC (1946-52)  The EDSAC (1947-49)  Manchester Mark I (1948)  The UNIVAC I (1951) Ref Page 03 Chapter 1: Introduction to Computers Slide 10/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Generations  “Generation” in computer talk is a step in technology. It provides a framework for the growth of computer industry  Originally it was used to distinguish between various hardware technologies, but now it has been extended to include both hardware and software  Till today, there are five computer generations (Continued on next slide) Ref Page 03 Chapter 1: Introduction to Computers Slide 11/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Generations (Continued from previous slide..) Generatio Key hardware Key software Key Some n representativ technologies characteristic (Period) e systems technologies s First  Vacuum tubes  Machine  Bulky in size  ENIAC (1942-1955)  Electromagneti and assembly  Highly unreliable  EDVAC c relay memory languages  Limited  EDSAC  Punched  Stored commercial use and  UNIVAC I cards secondary program concept costly  IBM 701 storage  Mostly  Difficult scientific commercial production applications  Difficult to use Second  Transistors  Batch  Faster, smaller, more  Honeywell 400 (1955-1964)  Magnetic operating system reliable and easier to  IBM 7030 cores memory  High-level program than previous  CDC 1604  Magnetic tapes programming generation systems  UNIVAC LARC  Disks for secondary languages  Commercial production storage  Scientific was still difficult and and commercial costly applications (Continued on next slide) Ref Page 03 Chapter 1: Introduction to Computers Slide 12/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Generations (Continued from previous slide..) Generatio Key hardware Key software Key Some rep. n technologies characteristic systems (Period) technologies s Third  ICs with SSI and  Timesharing  Faster, smaller, more  IBM 360/370 (1964-1975) MSI technologies operating reliable, easier and  PDP-8  Larger magnetic system cheaper to produce  PDP-11 cores memory  Standardization  Commercially, easier  CDC 6600  Larger capacity of high-level to use, and easier to disks and programming upgrade than magnetic tapes languages previous generation secondary  Unbundling of systems storage software  Scientific, commercial  Minicomputers; from and interactive on- upward hardware line applications compatible family of computers (Continued on next slide) Ref Page 03 Chapter 1: Introduction to Computers Slide 13/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Generations (Continued from previous slide..) Generation Key hardware Key software Key Some rep. (Period) characteristic systems Technologies technologies s Fourth  ICs with  Operating systems for  Small, affordable,  IBM PC and (1975-1989) VLSI technology PCs with GUI and reliable, and easy its clones  Microprocessors; multiple windows on a to use PCs  Apple II semiconductor memory single terminal screen  More powerful  TRS-80  Larger capacity hard  Multiprocessing and  VAX 9000 disks as in-built OS with reliable concurrent mainframe  CRAY-1 secondary storage  CRAY-2 programming systems  Magnetic tapes and languages and  CRAY-X/MP floppy disks as portable  UNIX operating system supercomputers storage media with C programming  Totally  Personal computers language general purpose  Supercomputers based  Object-oriented design machines on parallel and programming  Easier to produce vector processing commercially  PC, Network-based, and symmetric and supercomputing  Easier to upgrade multiprocessing applications  Rapid technologies software  Spread of high- development speed computer possible networks (Continued on next slide) Ref Page 03 Chapter 1: Introduction to Computers Slide 14/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Generations (Continued from previous slide..) Generatio Key hardware Key software Key Some rep. n technologies characteristic systems (Period) technologies s Fifth  ICs with ULSI  Micro-kernel based,  Portable computers  IBM notebooks (1989- technology multithreading,  Powerful, cheaper,  Pentium PCs Presen  Larger capacity distributed OS reliable, and easier  SUN t) main memory,  Parallel to use desktop Workstations hard disks with programming machines  IBM SP/2 RAID support libraries like MPI &  Powerful  SGI Origin  Optical disks as PVM supercomputer 2000 portable read-only  JAVA s  PARAM storage media  World Wide Web  High uptime due to 10000  Notebooks,  Multimedia, hot-pluggable powerful Internet components desktop PCs application  Totally and s general purpose workstations  More machines  Powerful complex  Easier to servers, supercomputing produce supercomputers applications commercially,  Internet easier to upgrade  Cluster computing  Rapid software development possible Ref Page 03 Chapter 1: Introduction to Computers Slide 15/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Electronic Devices Used in Computers of Different Generations (a) A Vacuum Tube (b) A Transistor (c) An IC Chip Ref Page 03 Chapter 1: Introduction to Computers Slide 16/17 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Key Words/Phrases  Computer  Integrated Circuit (IC)  Computer generations  Large Scale Integration (VLSI)  Computer Supported Cooperative  Medium Scale Integration (MSI) Working (CSCW)  Microprocessor  Data  Personal Computer (PC)  Data processing  Second-generation computers  Data processor  Small Scale Integration (SSI)  First-generation computers  Stored program concept  Fourth-generation computers  Third-generation computers  Garbage-in-garbage-out (GIGO)  Transistor  Graphical User Interface (GUI)  Ultra Large Scale Integration  Groupware (ULSI)  Information  Vacuum tubes Ref Page 03 Chapter 1: Introduction to Computers Slide 17/17 CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeeepp KK.. SSiinhnhaa && PPrriititi SSiia nnha h Ref. Page Chapter 2: Basic Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapter you will learn about:  Basic operations performed by all types of computer systems  Basic organization of a computer system  Input unit and its functions  Output unit and its functions  Storage unit and its functions  Types of storage used in a computer system (Continued on next slide) Ref. Page 15 Chapter 2: Basic Computer Organization Slide 2/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives (Continued from previous slide..)  Arithmetic Logic Unit (ALU)  Control Unit (CU)  Central Processing Unit (CPU)  Computer as a system Ref. Page 15 Chapter 2: Basic Computer Organization Slide 3/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha The Five Basic Operations of a Computer System  Inputting. The process of entering data and instructions into the computer system  Storing. Saving data and instructions to make them readily available for initial or additional processing whenever required  Processing. Performing arithmetic operations (add, subtract, multiply, divide, etc.) or logical operations (comparisons like equal to, less than, greater than, etc.) on data to convert them into useful information (Continued on next slide) Ref. Page 15 Chapter 2: Basic Computer Organization Slide 4/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha The Five Basic Operations of a Computer System  Outputting. The process of producing useful information or results for the user such as a printed report or visual display  Controlling. Directing the manner and sequence in which all of the above operations are performed Ref. Page 15 Chapter 2: Basic Computer Organization Slide 5/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Basic Organization of a Computer System Storage Unit Secondary Storage Program Information Input Outpu and Unit t (Results) Data Primary Unit Storage Control Unit Indicates flow of instructions and data Arithmetic Indicates the Logic control exercised by Unit the control unit Central Processing Unit (CPU) Ref. Page 15 Chapter 2: Basic Computer Organization Slide 6/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Input Unit An input unit of a computer system performs the following functions: 1. It accepts (or reads) instructions and data from outside world 2. It converts these instructions and data in computer acceptable form 3. It supplies the converted instructions and data to the computer system for further processing Ref. Page 15 Chapter 2: Basic Computer Organization Slide 7/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Output Unit An output unit of a computer system performs the following functions: 1. It accepts the results produced by the computer, which are in coded form and hence, cannot be easily understood by us 2. It converts these coded results to human acceptable (readable) form 3. It supplies the converted results to outside world Ref. Page 15 Chapter 2: Basic Computer Organization Slide 8/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Storage Unit The storage unit of a computer system holds (or stores) the following : 1. Data and instructions required for processing (received from input devices) 2. Intermediate results of processing 3. Final results of processing, before they are released to an output device Ref. Page 15 Chapter 2: Basic Computer Organization Slide 9/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Two Types of Storage  Primary storage  Used to hold running program instructions  Used to hold data, intermediate results, and results of ongoing processing of job(s)  Fast in operation  Small Capacity  Expensive  Volatile (looses data on power dissipation) (Continued on next slide) Ref. Page 17 Chapter 2: Basic Computer Organization Slide 10/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Two Types of Storage (Continued from previous slide..)  Secondary storage  Used to hold stored program instructions  Used to hold data and information of stored jobs  Slower than primary storage  Large Capacity  Lot cheaper that primary storage  Retains data even without power Ref. Page 17 Chapter 2: Basic Computer Organization Slide 11/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Arithmetic Logic Unit (ALU) Arithmetic Logic Unit of a computer system is the place where the actual executions of instructions takes place during processing operation Ref. Page 17 Chapter 2: Basic Computer Organization Slide 12/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Control Unit (CU) Control Unit of a computer system manages and coordinates the operations of all other components of the computer system Ref. Page 17 Chapter 2: Basic Computer Organization Slide 13/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Central Processing Unit (CPU) Arithmetic Central Logic Control Unit = Processin + (CU) Unit g Unit (ALU) (CPU)  It is the brain of a computer system  It is responsible for controlling the operations of all other units of a computer system Ref. Page 17 Chapter 2: Basic Computer Organization Slide 14/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha The System Concept A system has following three characteristics: 1. A system has more than one element 2. All elements of a system are logically related 3. All elements of a system are controlled in a manner to achieve the system goal A computer is a system as it comprises of integrated components (input unit, output unit, storage unit, and CPU) that work together to perform the steps called for in the executing program Ref. Page 17 Chapter 2: Basic Computer Organization Slide 15/16 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Key Words/Phrases  Arithmetic Logic Unit (ALU)  Output interface  Auxiliary storage  Output unit  Central Processing Unit (CPU)  Outputting  Computer system  Primate storage  Control Unit (CU)  Processing  Controlling  Secondary storage  Input interface  Storage unit  Input unit  Storing  Inputting  System  Main memory Ref. Page 17 Chapter 2: Basic Computer Organization Slide 16/16 CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeepep KK.. SSiinhanha && PPrriititi SSiinhanha Ref Page Chapter 3: Number Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapter you will learn about:  Non-positional number system  Positional number system  Decimal number system  Binary number system  Octal number system  Hexadecimal number system (Continued on next slide) Ref Page 20 Chapter 3: Number Systems Slide 2/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives (Continued from previous slide..)  Convert a number’s base  Another base to decimal base  Decimal base to another base  Some base to another base  Shortcut methods for converting  Binary to octal number  Octal to binary number  Binary to hexadecimal number  Hexadecimal to binary number  Fractional numbers in binary number system Ref Page 20 Chapter 3: Number Systems Slide 3/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Number Systems Two types of number systems are:  Non-positional number systems  Positional number systems Ref Page 20 Chapter 3: Number Systems Slide 4/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Non-positional Number Systems  Characteristics  Use symbols such as I for 1, II for 2, III for 3, IIII for 4, IIIII for 5, etc  Each symbol represents the same value regardless of its position in the number  The symbols are simply added to find out the value of a particular number  Difficulty  It is difficult to perform arithmetic with such a number system Ref Page 20 Chapter 3: Number Systems Slide 5/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Positional Number Systems  Characteristics  Use only a few symbols called digits  These symbols represent different values depending on the position they occupy in the number (Continued on next slide) Ref Page 20 Chapter 3: Number Systems Slide 6/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Positional Number Systems (Continued from previous slide..)  The value of each digit is determined by: 1. The digit itself 2. The position of the digit in the number 3. The base of the number system (base = total number of digits in the number system)  The maximum value of a single digit is always equal to one less than the value of the base Ref Page 20 Chapter 3: Number Systems Slide 7/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Decimal Number System Characteristics  A positional number system  Has 10 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9). Hence, its base = 10  The maximum value of a single digit is 9 (one less than the value of the base)  Each position of a digit represents a specific power of the base (10)  We use this number system in our day-to-day life (Continued on next slide) Ref Page 20 Chapter 3: Number Systems Slide 8/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Decimal Number System (Continued from previous slide..) Example 258610 = (2 x 103) + (5 x 102) + (8 x 101) + (6 x 100) = 2000 + 500 + 80 + 6 Ref Page 20 Chapter 3: Number Systems Slide 9/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Number System Characteristic s  A positional number system  Has only 2 symbols or digits (0 and 1). Hence its base = 2  The maximum value of a single digit is 1 (one less than the value of the base)  Each position of a digit represents a specific power of the base (2)  This number system is used in computers (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 10/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Number System (Continued from previous slide..) Example 101012 = (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) x (1 x 20) = 16 + 0 + 4 + 0 + 1 = 2110 Ref Page 21 Chapter 3: Number Systems Slide 11/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Representing Numbers in Different Number Systems In order to be specific about which number system we are referring to, it is a common practice to indicate the base as a subscript. Thus, we write: 101012 = 2110 Ref Page 21 Chapter 3: Number Systems Slide 12/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Bi t  Bit stands for binary digit  A bit in computer terminology means either a 0 or a 1  A binary number consisting of n bits is called an n-bit number Ref Page 21 Chapter 3: Number Systems Slide 13/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Octal Number System Characteristics  A positional number system  Has total 8 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7). Hence, its base = 8  The maximum value of a single digit is 7 (one less than the value of the base  Each position of a digit represents a specific power of the base (8) (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 14/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Octal Number System (Continued from previous slide..)  Since there are only 8 digits, 3 bits (23 = 8) are sufficient to represent any octal number in binary Example 20578 = (2 x 83) + (0 x 82) + (5 x 81) + (7 x 80) = 1024 + 0 + 40 + 7 = 107110 Ref Page 21 Chapter 3: Number Systems Slide 15/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Hexadecimal Number System Characteristics  A positional number system  Has total 16 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). Hence its base = 16  The symbols A, B, C, D, E and F represent the decimal values 10, 11, 12, 13, 14 and 15 respectively  The maximum value of a single digit is 15 (one less than the value of the base) (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 16/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Hexadecimal Number System (Continued from previous slide..)  Each position of a digit represents a specific power of the base (16)  Since there are only 16 digits, 4 bits (24 = 16) are sufficient to represent any hexadecimal number in binary Example 1AF16 = (1 x 162) + (A x 161) + (F x 160) = 1 x 256 + 10 x 16 + 15 x 1 = 256 + 160 + 15 = 43110 Ref Page 21 Chapter 3: Number Systems Slide 17/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Number of Another Base to a Decimal Number Method Step 1: Determine the column (positional) value of each digit Step 2: Multiply the obtained column values by the digits in the corresponding columns Step 3: Calculate the sum of these products (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 18/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Number of Another Base to a Decimal Number (Continued from previous slide..) Example 47068 = ?10 Common 47068 = 4 x 83 + 7 x 82 + 0 x 81 + 6 x 80 values correspondin = 4 x 512 + 7 x 64 + 0 + 6 x 1 g digits multiplie = 2048 + 448 + 0 + 6 d by the Sum of these products = 250210 Ref Page 21 Chapter 3: Number Systems Slide 19/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Decimal Number to a Number of Another Base Division-Remainder Method Step 1: Divide the decimal number to be converted by the value of the new base Step 2: Record the remainder from Step 1 as the rightmost digit (least significant digit) of the new base number Step 3: Divide the quotient of the previous divide by the new base (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 20/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Decimal Number to a Number of Another Base (Continued from previous slide..) Step 4: Record the remainder from Step 3 as the next digit (to the left) of the new base number Repeat Steps 3 and 4, recording remainders from right to left, until the quotient becomes zero in Step 3 Note that the last remainder thus obtained will be the most significant digit (MSD) of the new base number (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 21/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Decimal Number to a Number of Another Base (Continued from previous slide..) Example 95210 = ?8 Solution: Remainder 8 952 s 0 119 7 14 6 1 0 1 Hence, 95210 = 16708 Ref Page 21 Chapter 3: Number Systems Slide 22/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Number of Some Base to a Number of Another Base Method Step 1: Convert the original number to a decimal number (base 10) Step 2: Convert the decimal number so obtained to the new base number (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 23/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Number of Some Base to a Number of Another Base (Continued from previous slide..) Example 5456 = ?4 Solution: Step 1: Convert from base 6 to base 10 5456 = 5 x 62 + 4 x 61 + 5 x 60 = 5 x 36 + 4 x 6 + 5 x 1 = 180 + 24 + 5 = 20910 (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 24/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Converting a Number of Some Base to a Number of Another Base (Continued from previous slide..) Step 2: Convert 20910 to base 4 4 209 Remainder s 52 13 1 0 3 1 0 3 Hence, 20910 = 31014 So, 5456 = 20910 = 31014 Thus, 5456 = 31014 Ref Page 21 Chapter 3: Number Systems Slide 25/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Binary Number to its Equivalent Octal Number Method Step 1: Divide the digits into groups of three starting from the right Step 2: Convert each group of three binary digits to one octal digit using the method of binary to decimal conversion (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 26/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Binary Number to its Equivalent Octal Number (Continued from previous slide..) Example 11010102 = ?8 Step 1: Divide the binary digits into groups of 3 starting from right 001 101 010 Step 2: Convert each group into one octal digit 0012 = 0 x 22 + 0 x 21 + 1 x 20 =1 1012 = 1 x 22 + 0 x 21 + 1 x 20 = 5 0102 = 0 x 22 + 1 x 21 + 0 x 20 = 2 Hence, 11010102 = 1528 Ref Page 21 Chapter 3: Number Systems Slide 27/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting an Octal Number to Its Equivalent Binary Number Method Step Convert each octal digit to a 3 digit binary number (the octal digits may be treated as 1: decimal for this conversion) Step 2: Combine all the binary groups (of 3 resulting digits each) into singl binary number a e (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 28/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting an Octal Number to Its Equivalent Binary Number (Continued from previous slide..) Example 5628 = ?2 Step 1: Convert each octal digit to 3 binary digits 58 = 1012, 68 = 1102, 28 = 0102 Step 2: 5628 Combine = 101 the 110binary 010groups 5 6 2 Hence, 5628 = 1011100102 Ref Page 21 Chapter 3: Number Systems Slide 29/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Binary Number to its Equivalent Hexadecimal Number Method Step 1: Divide the binary digits into groups of four starting from the right Step 2: Combine each group of four binary digits to one hexadecimal digit (Continued on next slide) Ref Page 21 Chapter 3: Number Systems Slide 30/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Binary Number to its Equivalent Hexadecimal Number (Continued from previous slide..) Example 1111012 = ?16 Step 1: Divide the binary digits into groups of four starting from the right 0011 1101 Step 2: Convert each group into a hexadecimal digit 00112 = 0 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 310 = 316 11012 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 310 = D16 Hence, 1111012 = 3D16 Ref Page 31 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Hexadecimal Number to its Equivalent Binary Number Method Step 1: Convert the decimal equivalent of each hexadecimal digit to a 4 digit binary number Step 2: Combine all the resulting binary groups (of 4 digits each) in a single binary number (Continued on next slide) Ref Page 32 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Hexadecimal Number to its Equivalent Binary Number (Continued from previous slide..) Example 2AB16 = ?2 Step 1: Convert each hexadecimal digit to a 4 digit binary number = 00102 216 = 210 A16 = 1010 = 10102 B16 = 1110 = 10112 Ref Page 33 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Shortcut Method for Converting a Hexadecimal Number to its Equivalent Binary Number (Continued from previous slide..) Step 2: Combine the binary groups 2AB16 = 0010 1010 1011 2 A B Hence, 2AB16 = 0010101010112 Ref Page 34 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Fractional Numbers Fractional numbers are formed same way as decimal number system In general, a number in a number system with base b would be written as: an an-1… a0. a-1 a-2 … a-m And would be interpreted to mean: an x bn + an-1 x bn-1 + … + a0 x b0 + a-1 x b-1 + a-2 x b-2 + … The+ asymbols -m x b -m an, …, in above representation an-1, a-m should be one of the b symbols allowed in the number system Ref Page 35 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Formation of Fractional Numbers in Binary Number System (Example) Binary Point Position 4 3 2 1 0. -1 -2 -3 -4 Position Value 24 23 22 21 20 2-1 2-2 2-3 2-4 Quantity 16 8 4 2 1 1/ 1/ 1/ 1/ 2 4 8 16 Represente d (Continued on next slide) Ref Page 36 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Formation of Fractional Numbers in Binary Number System (Example) (Continued from previous slide..) Example 110.1012 = 1 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 0 x 2-2 + 1 x 2-3 = 4 + 2 + 0 + 0.5 + 0 + 0.125 = 6.62510 Ref Page 37 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Formation of Fractional Numbers in Octal Number System (Example) Octal Point Position 3 2 1 0. -1 -2 -3 Position Value 83 82 81 80 8-1 8-2 8-3 Quantity 512 64 8 1 1/ 1/ 1/ 8 64 512 Represente d (Continued on next slide) Ref Page 38 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Formation of Fractional Numbers in Octal Number System (Example) (Continued from previous slide..) Example 127.548 = 1 x 82 + 2 x 81 + 7 x 80 + 5 x 8-1 + 4 x 8-2 = 64 + 16 + 7 + 5/8 + 4/64 = 87 + 0.625 + 0.0625 = 87.687510 Ref Page 39 Chapter 3: Number Systems Slide 31/40 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Key Words/Phrases  Base  Least Significant Digit (LSD)  Binary number system  Memory dump  Binary point  Most Significant Digit (MSD)  Bit  Non-positional number  Decimal number system system  Division-Remainder technique  Number system  Fractional numbers  Octal number system  Hexadecimal number system  Positional number system Ref Page 40 Chapter 3: Number Systems Slide 31/40 CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeeepp KK.. SSiinhnhaa && PPrriititi SSiia nnha h Ref. Page Chapter 4: Computer Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapter you will learn about:  Computer data  Computer codes: representation of data in binary  Most commonly used computer codes  Collating sequence Ref. Page 36 Chapter 4: Computer Codes Slide 2/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Data Types  Numeric Data consists of only numbers 0, 1, 2, …, 9  Alphabetic Data consists of only the letters A, B, C, …, Z, in both uppercase and lowercase, and blank character  Alphanumeric Data is a string of symbols where a symbol may be one of the letters A, B, C, …, Z, in either uppercase or lowercase, or one of the digits 0, 1, 2, …, 9, or a special character, such as + - * / ,. ( ) = etc. Ref. Page 36 Chapter 4: Computer Codes Slide 3/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Codes  Computer codes are used for internal representation of data in computers  As computers use binary numbers for representation, computer internal data schemes codes use binary coding  In binary coding, every symbol that appears in the data is represented by a group of bits  The group of bits used to represent a symbol is called a byte (Continued on next slide) Ref. Page 36 Chapter 4: Computer Codes Slide 4/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Computer Codes (Continued from previous slide..)  As most modern coding schemes use 8 bits to represent a symbol, the term byte is often used to mean a group of 8 bits  Commonly used computer codes are BCD, EBCDIC, and ASCII Ref. Page 36 Chapter 4: Computer Codes Slide 5/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha BCD  BCD stands for Binary Coded Decimal  It is one of the early computer codes  It uses 6 bits to represent a symbol  It can represent 64 (26) different characters Ref. Page 36 Chapter 4: Computer Codes Slide 6/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Alphabetic and Numeric Characters in BCD BCD Code Octal BCD Code Octal Char Char Zone Digit Zone Digit A 11 0001 61 N 10 0101 45 B 11 0010 62 O 10 0110 46 C 11 0011 63 P 10 0111 47 D 11 0100 64 Q 10 1000 50 E 11 0101 65 R 10 1001 51 F 11 0110 66 S 01 0010 22 G 11 0111 67 T 01 0011 23 H 11 1000 70 U 01 0100 24 I 11 1001 71 V 01 0101 25 J 10 0001 41 W 01 0110 26 K 10 0010 42 X 01 0111 27 L 10 0011 43 Y 01 1000 30 M 10 0100 44 Z 01 1001 31 (Continued on next slide) Ref. Page 36 Chapter 4: Computer Codes Slide 7/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Alphabetic and Numeric Characters in BCD (Continued from previous slide..) BCD Code Octal Character Equivalen Zone Digit t 1 00 0001 01 2 00 0010 02 3 00 0011 03 4 00 0100 04 5 00 0101 05 6 00 0110 06 7 00 0111 07 8 00 1000 10 9 00 1001 11 0 00 1010 12 Ref. Page 36 Chapter 4: Computer Codes Slide 8/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha BCD Coding Scheme (Example 1) Example Show the binary digits used to record the word BASE in BCD Solution: B = 110010 in BCD binary notation A = 110001 in BCD binary notation S = 010010 in BCD binary notation E = 110101 in BCD binary notation So the binary digits 110010 110001 010010 110101 B A S E will record the word BASE in BCD Ref. Page 36 Chapter 4: Computer Codes Slide 9/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha BCD Coding Scheme (Example 2) Example Using octal notation, show BCD coding for the word DIGIT Solution: D = 64 in BCD octal notation I = 71 in BCD octal notation G = 67 in BCD octal notation I = 71 in BCD octal notation T = 23 in BCD octal notation Hence, BCD coding for the word DIGIT in octal notation will be 64 71 67 71 23 D I G I T Ref. Page 38 Chapter 4: Computer Codes Slide 10/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha EBCDIC  EBCDIC stands for Extended Binary Coded Decimal Interchange Code  It uses 8 bits to represent a symbol  It can represent 256 (28) different characters Ref. Page 38 Chapter 4: Computer Codes Slide 11/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Alphabetic and Numeric Characters in EBCDIC EBCDIC Code EBCDIC Code Hex Hex Char Char Digit Zone Digit Zone A 1100 0001 C1 N 1101 0101 D5 B 1100 0010 C2 O 1101 0110 D6 C 1100 0011 C3 P 1101 0111 D7 D 1100 0100 C4 Q 1101 1000 D8 E 1100 0101 C5 R 1101 1001 D9 F 1100 0110 C6 S 1110 0010 E2 G 1100 0111 C7 T 1110 0011 E3 H 1100 1000 C8 U 1110 0100 E4 I 1100 1001 C9 V 1110 0101 E5 J 1101 0001 D1 W 1110 0110 E6 K 1101 0010 D2 X 1110 0111 E7 L 1101 0011 D3 Y 1110 1000 E8 M 1101 0100 D4 Z 1110 1001 (ContinuedE9 on next slide) Ref. Page 38 Chapter 4: Computer Codes Slide 12/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Alphabetic and Numeric Characters in EBCDIC (Continued from previous slide..) EBCDIC Code Hexadecima Character Digit Zone l Equivalent 0 1111 0000 F0 1 1111 0001 F1 2 1111 0010 F2 3 1111 0011 F3 4 1111 0100 F4 5 1111 0101 F5 6 1111 0110 F6 7 1111 0111 F7 8 1111 1000 F8 9 1111 1001 F9 Ref. Page 38 Chapter 4: Computer Codes Slide 13/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Zoned Decimal Numbers  Zoned decimal numbers are used to represent numeric values (positive, negative, or unsigned) in EBCDIC  A sign indicator (C for plus, D for minus, and F for unsigned) is used in the zone position of the rightmost digit  Zones for all other digits remain as F, the zone value for numeric characters in EBCDIC  In zoned format, there is only one digit per byte Ref. Page 38 Chapter 4: Computer Codes Slide 14/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Examples Zoned Decimal Numbers Numeric Value EBCDIC Sign Indicator 345 F3F4F5 F for unsigned +345 F3F4C5 C for positive -345 F3F4D5 D for negative Ref. Page 38 Chapter 4: Computer Codes Slide 15/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Packed Decimal Numbers  Packed decimal numbers are formed from zoned decimal numbers in the following manner: Step 1: The zone half and the digit half of the rightmost byte are reversed Step 2: All remaining zones are dropped out  Packed decimal format requires fewer number of bytes than zoned decimal format for representing a number  Numbers represented in packed decimal format can be used for arithmetic operations Ref. Page 38 Chapter 4: Computer Codes Slide 16/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Examples of Conversion of Zoned Decimal Numbers to Packed Decimal Format Numeric Value EBCDIC Sign Indicator 345 F3F4F5 345F +345 F3F4C5 345C -345 F3F4D5 345D 3456 F3F4F5F6 03456F Ref. Page 38 Chapter 4: Computer Codes Slide 17/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha EBCDIC Coding Scheme Example Using binary notation, write EBCDIC coding for the word BIT. How many bytes are required for this representation? Solution: B = 1100 0010 in EBCDIC binary notation I = 1100 1001 in EBCDIC binary notation T = 1110 0011 in EBCDIC binary notation Hence, EBCDIC coding for the word BIT in 11000010 11001001 binary notation will be 11100011 B I T 3 bytes will be required for this representation because each letter requires 1 byte (or 8 bits) Ref. Page 38 Chapter 4: Computer Codes Slide 18/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha ASCII  ASCII stands for American Standard Code for Information Interchange.  ASCII is of two types – ASCII-7 and ASCII-8  ASCII-7 uses 7 bits to represent a and symbol represent 128 (27) different characters can  ASCII-8 uses 8 bits to represent a and symbol represent 256 (28) different characters can  First 128 characters in ASCII-7 and ASCII-8 are same Ref. Page 38 Chapter 4: Computer Codes Slide 19/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Numeric and Alphabetic Characters in ASCII ASCII-7 / ASCII-8 Hexadecimal Character Zone Digit Equivalent 0 0011 0000 30 1 0011 0001 31 2 0011 0010 32 3 0011 0011 33 4 0011 0100 34 5 0011 0101 35 6 0011 0110 36 7 0011 0111 37 8 0011 1000 38 9 0011 1001 39 (Continued on next slide) Ref. Page 38 Chapter 4: Computer Codes Slide 20/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Numeric and Alphabetic Characters in ASCII (Continued from previous slide..) ASCII-7 / ASCII-8 Hexadecimal Character Zone Digit Equivalent A 0100 0001 41 B 0100 0010 42 C 0100 0011 43 D 0100 0100 44 E 0100 0101 45 F 0100 0110 46 G 0100 0111 47 H 0100 1000 48 I 0100 1001 49 J 0100 1010 4A K 0100 1011 4B L 0100 1100 4C M 0100 1101 4D (Continued on next slide) Ref. Page 38 Chapter 4: Computer Codes Slide 21/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Coding of Numeric and Alphabetic Characters in ASCII (Continued from previous slide..) ASCII-7 / ASCII-8 Hexadecima Character Zone Digit l Equivalent N 0100 1110 4E O 0100 1111 4F P 0101 0000 50 Q 0101 0001 51 R 0101 0010 52 S 0101 0011 53 T 0101 0100 54 U 0101 0101 55 V 0101 0110 56 W 0101 0111 57 X 0101 1000 58 Y 0101 1001 59 Z 0101 1010 5A Ref. Page 38 Chapter 4: Computer Codes Slide 22/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha ASCII-7 Coding Scheme Example Write binary coding for the word BOY in ASCII-7. How many bytes are required for this representation? Solution: B = 1000010 in ASCII-7 binary notation O = 1001111 in ASCII-7 binary notation Y = 1011001 in ASCII-7 binary notation Hence, binary coding for the word BOY in ASCII-7 will be 1000010 1001111 1011001 B O Y Since each character in ASCII-7 requires one byte for its representation and there are 3 characters in the word BOY, 3 bytes will be required for this representation Ref. Page 38 Chapter 4: Computer Codes Slide 23/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha ASCII-8 Coding Scheme Example Write binary coding for the word SKY in ASCII-8. How many bytes are required for this representation? Solution: S = 01010011 in ASCII-8 binary notation K = 01001011 in ASCII-8 binary notation Y = 01011001 in ASCII-8 binary notation Hence, binary coding for the word SKY in ASCII-8 will be 01010011 01001011 01011001 S K Y Since each character in ASCII-8 requires one byte for its representation and there are 3 characters in the word SKY, 3 bytes will be required for this representation Ref. Page 38 Chapter 4: Computer Codes Slide 24/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Unicod e  Why Unicode:  No single encoding system supports all languages  Different encoding systems conflict  Unicode features:  Provides a consistent way of encoding multilingual plain text  Defines codes for characters used in all major languages of the world  Defines codes for special characters, mathematical symbols, technical symbols, and diacritics Ref. Page 38 Chapter 4: Computer Codes Slide 25/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Unicod e  Unicode features (continued):  Capacity to encode as many as a million characters  Assigns each character a unique numeric value and name  Reserves a part of the code space for private use  Affordssimplicity and consistency of ASCII, even corresponding characters have same code  Specifies an algorithm for the presentation of text with bi-directional behavior  Encoding Forms  UTF-8, UTF-16, UTF-32 Ref. Page 38 Chapter 4: Computer Codes Slide 26/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Collating Sequence  Collating sequence defines the assigned ordering among the characters used by a computer  Collating sequence may vary, depending on the type of computer code used by a particular computer  In most computers, collating sequences follow the following rules: 1. Letters are considered in alphabetic order (A < B < C … < Z) 2. Digits are considered in numeric order (0 < 1 < 2 … < 9) Ref. Page 38 Chapter 4: Computer Codes Slide 27/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Sorting in EBCDIC Example Suppose a computer EBCDIC as internal uses representation of its In which will characters.sort the strings 23, A1, order computer 1A? this Solution: In EBCDIC, numeric characters are treated to be greater than alphabetic characters. Hence, in the said computer, numeric characters will be placed after alphabetic characters and the given string will be treated as: A1 < 1A < 23 Therefore, the sorted sequence will be: A1, 1A, 23. Ref. Page 38 Chapter 4: Computer Codes Slide 28/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Sorting in ASCII Example Suppose a computer uses ASCII for its internal representation of characters. In which order will this computer sort the strings 23, A1, 1A, a2, 2a, aA, and Aa? Solution: In ASCII, numeric characters are treated to be less than alphabetic characters. Hence, in the said computer, numeric characters will be placed before alphabetic characters and the given string will be treated as: 1A < 23 < 2a < A1 < Aa < a2 < aA Therefore, the sorted sequence will be: 1A, 23, 2a, A1, Aa, a2, and aA Ref. Page 38 Chapter 4: Computer Codes Slide 29/30 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Key Words/Phrases  Alphabetic data  Alphanumeric data  American Standard Code for Information Interchange (ASCII)  Binary Coded Decimal (BCD) code  Byte  Collating sequence  Computer codes  Control characters  Extended Binary-Coded Decimal Interchange Code (EBCDIC)  Hexadecimal equivalent  Numeric data  Octal equivalent  Packed decimal numbers  Unicode  Zoned decimal numbers Ref. Page 38 Chapter 4: Computer Codes Slide 30/30 CCoommppuutterer FFununddaammenenttaallss:: PPrradadeeeepp KK.. SSiinhnhaa && PPrriititi SSiia nnha h Ref Page Chapter 5: Computer Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Learning Objectives In this chapter you will learn about:  Reasons for using binary instead of decimal numbers  Basic arithmetic operations using binary numbers  Addition (+)  Subtraction (-)  Multiplication (*)  Division (/) Ref Page 49 Chapter 5: Computer Arithmetic Slide 2/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary over Decimal  Information is handled in a computer by electronic/ electrical components  Electronic components operate in binary mode (can only indicate two states – on (1) or off (0)  Binary number system has only two digits (0 and 1), and is suitable for expressing two possible states  In binary system, computer circuits only have to handle two binary digits rather than ten decimal digits causing:  Simpler internal circuit design  Less expensive  More reliable circuits  Arithmetic rules/processes possible with binary numbers Ref Page 49 Chapter 5: Computer Arithmetic Slide 3/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Examples of a Few Devices that work in Binary Mode Binary On (1) Off (0) State Bulb Switch Circuit Pulse Ref Page 49 Chapter 5: Computer Arithmetic Slide 4/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Arithmetic  Binary arithmetic is simple to learn as binary number system has only two digits – 0 and 1  Following slides show rules and example for the four basic arithmetic operations using binary numbers Ref Page 49 Chapter 5: Computer Arithmetic Slide 5/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Addition Rule for binary addition is as follows: 0 +0=0 0 +1=1 1 +0=1 1 + 1 = 0 plus a carry of 1 to next higher column Ref Page 49 Chapter 5: Computer Arithmetic Slide 6/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Addition (Example 1) Example Add binary numbers 10011 and 1001 in both decimal and binary form Solution Binary Decimal carry 11 carry 1 10011 19 +100 +9 1 11100 28 In this example, carry are generated for first and second columns Ref Page 49 Chapter 5: Computer Arithmetic Slide 7/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Addition (Example 2) Example Add binary numbers 100111 and 11011 in both decimal and binary form Solution The addition of three 1s Binary Decimal can be broken up into two steps. First, we add only carry 11111 carr 1 two 1s giving 10 (1 + 1 = y 10). The third 1 is now added to this result to 100111 39 obtain 11 (a 1 sum with a 1 +11011 +27 carry). Hence, 1 + 1 + 1 = 1, plus a carry of 1 to next 1000010 higher column. 66 Ref Page 49 Chapter 5: Computer Arithmetic Slide 8/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Subtraction Rule for binary subtraction is as follows: 0 - 0 = 0 0 - 1 = 1 with a borrow from the next column 1 - 0 = 1 1 - 1 = 0 Ref Page 49 Chapter 5: Computer Arithmetic Slide 9/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Subtraction (Example) Example Subtract 011102 from 101012 Solution 12 0202 10101 -01110 00111 Note: Go through explanation given in the book Ref Page 52 Chapter 5: Computer Arithmetic Slide 10/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complement of a Number Number of digits in the number C = Bn - 1 - N Complement Base of the The number of the number number Ref Page 52 Chapter 5: Computer Arithmetic Slide 11/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complement of a Number (Example 1) Example Find the complement of 3710 Solution Since the number has 2 digits and the value of base is 10, (Base)n - 1 = 102 - 1 = 99 Now 99 - 37 = 62 Hence, complement of 3710 = 6210 Ref Page 52 Chapter 5: Computer Arithmetic Slide 12/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complement of a Number (Example 2) Example Find the complement of 68 Solution Since number has 1 digit and the value of (Base)n - 1 = 81 - 1 = 710 = 78 the base is 8, Now 78 - 68 = 18 Hence, complement of 68 = 18 Ref Page 52 Chapter 5: Computer Arithmetic Slide 13/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complement of a Binary Number Complement of a binary number can be obtained by transforming all its 0’s to 1’s and all its 1’s to 0’s Example Complement of 1 0 1 1 0 1 0 is 0 1 0 0 1 Ref Page 52 Chapter 5: Computer Arithmetic Slide 14/29 0 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complementary Method of Subtraction Involves following 3 steps: Step 1: Find the the number complement of are you subtracting (subtrahend) from which Step 2: Add this to you the number are taking away (minuend) add it to the result; if there is no carry, recomplement obtain the Step 3: If sumthere is a acarry and attach of sign negative 1, Complementary subtraction is an additive approach of subtraction Ref Page 52 Chapter 5: Computer Arithmetic Slide 15/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complementary Subtraction (Example 1) Example: Subtract 5610 from 9210 using complementary method. Solution Step 1: Complement of 5610 = 102 - 1 - 56 = 99 – 56 The result may be = 4310 verified using the method of Step 2: 92 + 43 (complement of 56) normal = 135 (note 1 as carry) subtraction: Step 3: 35 + 1 (add 1 carry to sum) 92 - 56 = 36 Result = 36 Ref Page 52 Chapter 5: Computer Arithmetic Slide 16/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Complementary Subtraction (Example 2) Example Subtract 3510 from 1810 using complementary method. Solution Step 1: Complement of 3510 Step 3: Since there is no carry, = 102 - 1 - 35 re-complement the sum and = 99 - 35 attach a negative sign to = 6410 obtain the result. Result = -(99 - 82) Step 2: 18 = -17 + 64 (complement of 35) The result may be verified using normal 82 subtraction: 18 - 35 = -17 Ref Page 52 Chapter 5: Computer Arithmetic Slide 17/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Subtraction Using Complementary Method (Example 1) Example Subtract 01110002 (5610) from 10111002 (9210) using complementary method. Solution 1011100 +1000111 (complement of 0111000) 10100011 1 (add the carry of 1) 0100100 Result = 01001002 = 3610 Ref Page 52 Chapter 5: Computer Arithmetic Slide 18/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Subtraction Using Complementary Method (Example 2) Example Subtract 1000112 (3510) from 0100102 (1810) using complementary method. Solution 010010 +011100 (complement of 100011) 101110 Since there is no carry, we have to complement the sum and attach a negative sign to it. Hence, Result = -0100012 (complement of 1011102) = -1710 Ref Page 52 Chapter 5: Computer Arithmetic Slide 19/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Multiplication Table for binary multiplication is as follows: 0x0=0 0x1=0 1x0=0 1x1=1 Ref Page 52 Chapter 5: Computer Arithmetic Slide 20/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Multiplication (Example 1) Example Multiply the binary numbers 1010 and 1001 Solution 1010 Multiplican d Multiplier x1001 1010 Partial Product 0000 Partial Product 0000 Partial Product 1010 Partial Product 1011010 Final Product (Continued on next slide) Ref Page 52 Chapter 5: Computer Arithmetic Slide 21/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Multiplication (Example 2) (Continued from previous slide..) Whenever a 0 appears in the multiplier, a separate partial product consisting of a string of zeros need not be generated (only a shift will do). Hence, 1010 x1001 1010 1010SS (S = left shift) 1011010 Ref Page 52 Chapter 5: Computer Arithmetic Slide 22/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Division Table for binary division is as follows: 1 0 = Divide by zero error 0 1=0 2 0 = Divide by zero error 1 1=1 As in the decimal number system (or in any other number system), division by zero is meaningless The computer deals with this problem by raising an error condition called ‘Divide by zero’ error Ref Page 52 Chapter 5: Computer Arithmetic Slide 23/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Rules for Binary Division 1. Start from the left of the dividend 2. Perform a series of subtractions in which the divisor is subtracted from the dividend 3. If subtraction is possible, put a 1 in the quotient and subtract the divisor from the corresponding digits of dividend 4. If subtraction is not possible (divisor greater than remainder), record a 0 in the quotient 5. Bring down the next digit to add to the remainder digits. Proceed as before in a manner similar to long division Ref Page 52 Chapter 5: Computer Arithmetic Slide 24/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Binary Division (Example 1) Example Divide 1000012 by 1102 Solution 0101 (Quotient) 110 100001 (Dividend) 110 1 Divisor greater than 100, so put 0 in quotient 1000 2 Add digit from dividend to group used above 110 3 Subtraction possible, so put 1 in quotient 100 4 Remainder from subtraction plus digit from dividend 110 5 Divisor greater, so put 0 in quotient 1001 6 Add digit from dividend to group 110 7 Subtraction possible, so put 1 in quotient 11 Remainder Ref Page 52 Chapter 5: Computer Arithmetic Slide 25/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Additive Method of Multiplication and Division Most computers use the additive method for performing multiplication and division operations because it simplifies the internal circuit design of computer systems Example 4 x 8 = 8 + 8 + 8 + 8 = 32 Ref Page 52 Chapter 5: Computer Arithmetic Slide 26/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Rules for Additive Method of Division  Subtract the divisor repeatedly from the dividend until the result of subtraction becomes less than or equal to zero  If result of subtraction is zero, then:  quotient = total number of times subtraction was performed  remainder = 0  If result of subtraction is less than zero, then:  quotient = total number of times subtraction was performed minus 1  remainder = result of the subtraction previous to the last subtraction Ref Page 52 Chapter 5: Computer Arithmetic Slide 27/29 Computer Fundamentals: Pradeep K. Sinha & Priti Sinha Additive Method of Division (Example) Example Divide 3310 by 610 using the method of addition Solution: 33 - 6 = 27 27 - 6 = 21 Since the result of the last 21 - 6 = 15 subtraction is less than zero, 15 - 6 = 9 9-6= 3 Quotient = 6 - 1 (ignore last 3 - 6 = -3 subtraction) = 5 Total subtractions = 6 Remainder = 3 (result of previous subtraction) Ref Page 52 Chapter 5: Computer Arithmetic Slide 28/29 Computer Fundamentals: Pr

Use Quizgecko on...
Browser
Browser