LECTURE 1-2. Introduction and Number Systems

Similar documents
Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Introduction to Numbering Systems

CHAPTER 2 (b) : AND CODES

BINARY SYSTEM. Binary system is used in digital systems because it is:

Octal & Hexadecimal Number Systems. Digital Electronics

CS & IT Conversions. Magnitude 10,000 1,

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

Number representations

Digital Systems and Binary Numbers

COMP Overview of Tutorial #2

Level ISA3: Information Representation

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

Number Systems CHAPTER Positional Number Systems

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

in this web service Cambridge University Press

EEM 232 Digital System I

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Number Systems. TA: Mamun. References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Octal and Hexadecimal Integers

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Fundamentals of Programming (C)

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

Lecture 2: Number Systems

MC1601 Computer Organization

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Decimal/Binary Conversion on the Soroban

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

Number Systems. Both numbers are positive

Chapter 2 Binary Values and Number Systems

Electronic Data and Instructions

CHW 261: Logic Design

CHAPTER 2 Number Systems

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Advanced Computer Networks. Rab Nawaz Jadoon DCS. Assistant Professor COMSATS University, Lahore Pakistan. Department of Computer Science

Switching Circuits and Logic Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

Number Systems Base r

Binary Representations and Arithmetic

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

NUMERIC SYSTEMS USED IN NETWORKING

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Digital Fundamentals

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Outline. What Digit? => Number System. Decimal (base 10) Significant Digits. Lect 03 Number System, Gates, Boolean Algebra. CS221: Digital Design

The. Binary. Number System

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

Final Labs and Tutors

Lecture (02) Operations on numbering systems

CMPE223/CMSE222 Digital Logic Design. Positional representation

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

EE 8351 Digital Logic Circuits Ms. J.Jayaudhaya, ASP/EEE

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

UNIT1: COMPUTERNUMBER SYSTEM

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

Lecture (01) Introduction Number Systems and Conversion (1)

Electronics Engineering ECE / E & T

T02 Tutorial Slides for Week 2

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2

Module 1: Information Representation I -- Number Systems

Digital Systems and Binary Numbers

Number Systems & Encoding

Binary Systems and Codes

Number System. Introduction. Decimal Numbers

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

Microcomputers. Outline. Number Systems and Digital Logic Review

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

6. Binary and Hexadecimal

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

Appendix 2 Number Representations

LESSON TITLE. Language English Local Language Introduction to Computer Science. Mr. VAR Sovannrath Submission Date October 30th, 2014 Version 1.

Slide Set 1. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

Chapter 1 Review of Number Systems

Objectives. Connecting with Computer Science 2

CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College September 6, 2018

ECE 20B, Winter Purpose of Course. Introduction to Electrical Engineering, II. Administration

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

umber Systems bit nibble byte word binary decimal

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

Chapter 2 Number Systems and Codes Dr. Xu

Digital Logic Lecture 2 Number Systems

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Binary Values. CSE 410 Lecture 02

MACHINE LEVEL REPRESENTATION OF DATA

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

TOPIC: NUMBER SYSTEMS

Chapter 1 Emad Felemban

Lesson Plan. Preparation

Transcription:

LECTURE 1-2 Introduction and Number Systems 1

BASIC INFORMATION Course Code: CSE 115 Course Title: Computing Concepts Course Teacher: Dr. Muhammad Asif H. Khan (Mfs), Associate Professor, Dept. of Computer Sci. & Eng., Dhaka University. Text Book 1. Programming in ANSI C E. Balagurusamy 2. Problem Solving and Program Design in C (7 th Edition) -- Jeri R. Hanly & Elliot B. Koffman

REFERENCE BOOKS Other Books You can Look into: 1. C The Complete Reference Herbert Schildt

COURSE WEBSITE www.engrade.com How to use? Go to http://www.engrade.com/students If you do not have an account with Engrade, then Join as a student and provide the Access Code. Collect the Access code from me during the next lab session. If you already have an account, just add a new course by providing the Access Code. Why to Use? All lecture notes and other deliverables will be provided through Engrade.

COURSE EVALUATION Topic Marks Attendance (Randomly checked) 5 Class Performance and HW 10 Quizzes (4 in total) 20 Midterm-1 15 Midterm-2 25 Final 25

WHAT IS A COMPUTER Computer Device capable of performing computations and making logical decisions Computer programs A set of instructions that control computer s processing of data to do a particular work Hardware Various devices comprising computer Software Application programs developed to do a specific set of tasks for the users

INTRODUCTION TO NUMBER SYSTEMS We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are: Binary Base 2 Octal Base 8 Hexadecimal Base 16 7

CHARACTERISTICS OF NUMBER SYSTEMS 1) The digits are consecutive. 2) The number of digits is equal to the size of the base. 3) Zero is always the first digit. 4) The base number is never a digit. 5) When 1 is added to the largest digit, a sum of zero and a carry of one results. 6) Numeric values determined by the implicit positional values of the digits. 8

SIGNIFICANT DIGITS Binary: 11101101 Most significant digit Least significant digit Hexadecimal: 1D63A7A Most significant digit Least significant digit 9

BINARY NUMBER SYSTEM Also called the Base 2 system Two digits: 0 and 1 The binary number system is used to model the series of electrical signals computers use to represent information 0 represents the no voltage or an off state 1 represents the presence of voltage or an on state 10

BINARY NUMBERING SCALE Base 2 Number Base 10 Equivalent 000 0 001 1 010 2 011 3 100 4 101 5 110 6 111 7 Power Positional Value 2 0 1 2 1 2 2 2 4 2 3 8 2 4 16 2 5 32 2 6 64 2 7 128 11

DECIMAL TO BINARY CONVERSION The easiest way to convert a decimal number to its binary equivalent is to use the Division Algorithm This method repeatedly divides a decimal number by 2 and records the quotient and remainder The remainder digits (a sequence of zeros and ones) form the binary equivalent in least significant to most significant digit sequence 13

DIVISION ALGORITHM Convert 67 to its binary equivalent: 67 10 = x 2 Step 1: 67 / 2 = 33 R 1 Step 2: 33 / 2 = 16 R 1 Step 3: 16 / 2 = 8 R 0 Step 4: 8 / 2 = 4 R 0 Step 5: 4 / 2 = 2 R 0 Step 6: 2 / 2 = 1 R 0 Divide 67 by 2. Record quotient in next row Again divide by 2; record quotient in next row Repeat again Repeat again Repeat again Repeat again Step 7: 1 / 2 = 0 R 1 STOP when quotient equals 0 1 0 0 0 0 1 1 2 14

BINARY TO DECIMAL CONVERSION The easiest method for converting a binary number to its decimal equivalent is to use the Multiplication Algorithm Multiply the binary digits by increasing powers of two, starting from the right Then, to find the decimal number equivalent, sum those products 15

MULTIPLICATION ALGORITHM Convert (10101101) 2 to its decimal equivalent: Binary 1 0 1 0 1 1 0 1 x x x x x x x x Positional Values Products 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 128 +64+ 32+0+8+ 4 +0 + 1 173 10 16

OCTAL NUMBER SYSTEM Also known as the Base 8 System Uses digits 0-7 Readily converts to binary Groups of three (binary) digits can be used to represent each octal digit Also uses multiplication and division algorithms for conversion to and from base 10 17

DECIMAL TO OCTAL CONVERSION Convert 427 10 to its octal equivalent: 427 / 8 = 53 R3 Divide by 8; R is LSD 53 / 8 = 6 R5 Divide Q by 8; R is next digit 6 / 8 = 0 R6 Repeat until Q = 0 653 8 18

OCTAL TO DECIMAL CONVERSION Convert 653 8 to its decimal equivalent: Octal Digits Positional Values Products 6 5 3 x x x 8 2 8 1 8 0 384 + 40 + 3 427 10 19

OCTAL TO BINARY CONVERSION Each octal number converts to 3 binary digits To convert 653 8 to binary, just substitute code: 6 5 3 110 101 011 20

HEXADECIMAL NUMBER SYSTEM Base 16 system Uses digits 0-9 & letters A,B,C,D,E,F Groups of four bits represent each base 16 digit 21

DECIMAL TO HEXADECIMAL CONVERSION Convert 830 10 to its hexadecimal equivalent: 830 / 16 = 51 R14 51 / 16 = 3 R3 3 / 16 = 0 R3 = E in Hex 33E 16 22

HEXADECIMAL TO DECIMAL CONVERSION Convert 3B4F 16 to its decimal equivalent: Hex Digits Positional Values Products 3 B 4 F x x x x 16 3 16 2 16 1 16 0 12288 +2816 + 64 +15 15,183 10 23

BINARY TO HEXADECIMAL CONVERSION The easiest method for converting binary to hexadecimal is to use a substitution code Each hex number converts to 4 binary digits 24

SUBSTITUTION CODE Convert 010101101010111001101010 2 to hex using the 4-bit substitution code : A 5 6 A E 6 0101 0110 1010 1110 0110 1010 56AE6A 16 25

SUBSTITUTION CODE Substitution code can also be used to convert binary to octal by using 3-bit groupings: 25527152 8 26

SUBTRACTION BY ADDITION Follow these steps: take the "complement" of the number you are subtracting (I will show you how) add it to the number you are subtracting from discard the extra "1" on the left 27

COMPLEMENT The "complement" is the number to add to make 10 (or 100, 1000, etc, depending on how many digits you have) Example The complement of 3 is 7, because 3+7=10 (you add 7 to make 10) Example: the complement of 85 is 15, because 85+15=100 Example: the complement of 111 is 889, because 111+889=1000 28

CALCULATING THE COMPLEMENT The basic idea is to find the difference between each digit and 9. That will get you to "999...", so you only need to add 1 to make it "1000... Steps Starting at the right (the "units" position) Skip over any zeros at the start For the first digit that isn't zero: find what would make it to 10 For all other digits: find what would make it to 9 What is the complement of 1700? 29

SUBTRACTION BY ADDITION Follow these steps: take the "complement" of the number you are subtracting add it to the number you are subtracting from discard the extra "1" on the left 30

SUBTRACTION BY ADDITION Example Find 653-372. Complement of 372 is 628 (verify yourself) 653 + 628 = 1281 Discard the leading 1, and that s your answer! 31

WHAT IF THE NUMBER YOU ARE SUBTRACTING HAS LESS DIGITS? How would you, for example, do 4567-56? the complement of 56 is 44, but we need to "pad it" out to 4 digits, so we end up with 9944. 4567 +9944 14511 32

COMPLEMENT Complement is the negative equivalent of a number. If we have a number N then complement of N will give us another number which is equivalent to N So if complement of N is M, then we can say M = -N So complement of M = -M = -(-N) = N So complement of complement gives the original number 33

TYPES OF COMPLEMENT For a number of base r, two types of complements can be found 1. r s complement 2. (r-1) s complement Definition: If N is a number of base r having n digits then r s complement of N = r n N and (r-1) s complement of N = r n -N-1 34

EXAMPLE Suppose N = (3675) 10 So we can find two complements of this number. The 10 s complement and the 9 s complement. Here n = 4 10 s complement of (3675) = 10 4-3675 = 6325 9 s complement of (3675) = 10 4-3675 -1 = 6324 35

SHORT CUT WAY TO FIND (R-1) S COMPLEMENT In the previous example we see that 9 s complement of 3675 is 6324. We can get the result by subtracting each digit from 9. Similarly for other base, the (r-1) s complement can be found by subtracting each digit from r-1 (the highest digit in that system). For binary 1 s complement is even more easy. Just change 1 to 0 and 0 to 1. (Because 1-1=0 and 1-0=1) 36

EXAMPLE: Find the (r-1) s complement in short cut method. (620143) 8 Ans: 157634 (A4D7E) 16 Ans: 5B281 (110100101) 2 Ans: 001011010 37

SHORT CUT WAY TO FIND R S COMPLEMENT From the definition we can say, r s complement of (N) = (r-1) s complement +1 So, we can first find the (r-1) s complement in short cut way then add 1 to get the r s complement. Example: r s complement of (620143) 8 =157634 + 1 = 157635 This method is a two step process. But we can find it in one step process also. 38

SHORT CUT WAY TO FIND R S COMPLEMENT One step process: Start from rightmost digit to left. Initial zeros will remain unchanged Rightmost non-zero digit will be subtracted from r Rest of the digits will be subtracted from r-1 Example: Find the 10 s complement of (529400) 10 Rightmost 2 zeros will not change, 4 will be subtracted from 10 and rest of the digits 529 will be subtracted from 9 So the result is 470600 39

Example Find the r s complement in short cut method. (8210) 10 Ans: 1790 (61352) 10 Ans: 38648 (6201430) 8 Ans: 1576350 (A4D7E0) 16 Ans: 5B2820 40

EXAMPLE FOR BINARY For binary: start from rightmost bit Up to first 1 no change. For rest of the bits toggle (Change 1 to 0 and 0 to 1) (11010010100) 2 Ans: 00101101100 (01101001011) 2 Ans: 10010110101 (10000000) 2 Ans: 10000000 41

USE OF COMPLEMENT Complement is used to perform subtraction using addition Mathematically A-B = A + (-B) So we can get the result of A-B by adding complement of B with A. So A-B = A + Complement of (B) 42