King Fahd University of Petroleum and Minerals

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Number Systems & Operations
Binary Addition Rules Adding Binary Numbers = = 1
CMP 101 Fundamentals of Computer and programming in C Rohit Khokher.
Arithmetic Operations and Circuits
King Fahd University of Petroleum and Minerals
Data Representation Computer Organization &
Data Representation COE 205
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
James Tam Non decimal math: doing math with non-base 10 number systems Addition, subtraction and multiplication with binary, octal and hexadecimal.
Integer Multiplication and Division
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Data Representation ICS 233
Binary Operations Math/Logical. Binary Math Decimal Addition Example ) Add = 15 Write down 5, carry ) Add 3 +
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Arithmetic Operations and Circuits
FIGURES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Chapter 7 Arithmetic Operations and Circuits Binary Arithmetic Addition –When the sum exceeds 1, carry a 1 over to the next-more-significant column.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Operations on Bits Arithmetic Operations Logic Operations
Integer Multiplication and Division
AEEE2031 Data Representation and Numbering Systems.
Combinational Circuits
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
1 CS151 Introduction to Digital Design Chapter 1 Lecture 3.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Number System Base b Use only digits of 0, 1, 2,…., b-1 Positional weights X = a n-1 b n-1 + a n-2 b n-2 + …. + a 0 b = 1x x10 1 +
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
CPS120: Introduction to Computer Science Computer Math: Addition and Subtraction.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
Week 1(Number System) Muhammad Ammad uddin Logic Design Lab I (CEN211)
Prepared By: Norakmar Binti Mohd Nadzari CHAPTER 2 ARITHMETIC AND LOGIC UNIT.
Data Representation COE 308 Computer Architecture
More Binary Arithmetic - Multiplication
Multiplication and Division basics
Positional Number Systems Decimal, Binary, Octal and Hexadecimal Numbers Wakerly Section
Digital Logic & Design Adil Waheed Lecture 02.
Data Representation ICS 233
Data Representation.
Integer Multiplication and Division
Digital Systems and Number Systems
Data Representation Binary Numbers Binary Addition
CHAPTER 1 : INTRODUCTION
COMPUTING FUNDAMENTALS
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Representation COE 301 Computer Organization
King Fahd University of Petroleum and Minerals
Computer Organization and Design
Computation in Other Bases
Digital Electronics and Microprocessors
Multiplication More complicated than addition
Reading: Study Chapter (including Booth coding)
BASIC MATH.
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Montek Singh Mon, Mar 28, 2011 Lecture 11
Data Representation ICS 233
Binary to Decimal Conversion
Introduction To Number Systems
COE 202: Digital Logic Design Number Systems Part 2
Data Representation COE 308 Computer Architecture
Presentation transcript:

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

Adding Bits 1 + 1 = 2, but 2 should be represented as (10)2 in binary Adding two bits: the sum is S and the carry is C Adding three bits: the sum is S and the carry is C X + Y C S + 0 0 0 + 1 0 1 1 + 0 0 1 1 + 1 1 0 + 0 0 0 + 1 0 1 1 + 0 0 1 1 + 1 1 0 1 + 0 0 1 1 + 1 1 0 1 + 0 1 0 1 + 1 1 1

Binary Addition Start with the least significant bit (rightmost bit) Add each pair of bits Include the carry in the addition, if present 1 carry 1 1 1 1 + (54) (29) 1 2 3 4 bit position: 5 6 7 1 1 1 1 (83)

Subtracting Bits Subtracting 2 bits (X – Y): we get the difference (D) and the borrow-out (B) shown as 0 or -1 Subtracting two bits (X – Y) with a borrow-in = -1: we get the difference (D) and the borrow-out (B) X – Y B D – 0 0 0 – 1 -1 1 1 – 0 0 1 1 – 1 0 0 -1 X – Y B D borrow-in -1 – 0 -1 1 -1 – 1 -1 0 -1 1 – 0 0 0 -1 1 – 1 -1 1

Binary Subtraction Start with the least significant bit (rightmost bit) Subtract each pair of bits Include the borrow in the subtraction, if present borrow -1 -1 -1 1 – (54) (29) 1 2 3 4 bit position: 5 6 7 1 1 1 (25)

Binary Multiplication Binary Multiplication table is simple: 0×0=0, 0×1=0, 1×0=0, 1×1=1 Multiplicand 11002 = 12 Multiplier × 11012 = 13 1100 0000 Product 100111002 = 156 n-bit multiplicand × n-bit multiplier = 2n-bit product Accomplished via shifting and addition Binary multiplication is easy 0 × multiplicand = 0 1 × multiplicand = multiplicand

Hexadecimal Addition 1 9 C 3 7 2 8 6 5 1 E 4 B + A F C D B Start with the least significant hexadecimal digits Let Sum = summation of two hex digits If Sum is greater than or equal to 16 Sum = Sum – 16 and Carry = 1 Example: 1 carry 1 1 9 C 3 7 2 8 6 5 1 E 4 B + 5 + B = 5 + 11 = 16 Since Sum ≥ 16 Sum = 16 – 16 = 0 Carry = 1 A F C D B

Hexadecimal Subtraction Start with the least significant hexadecimal digits Let Difference = subtraction of two hex digits If Difference is negative Difference = 16 + Difference and Borrow = -1 Example: A -1 borrow A -1 4 -1 9 C 3 7 2 8 6 5 1 E 4 B - Since 5 < B, Difference < 0 Difference = 16+5–11 = 10 Borrow = -1 8 8 1 1

Shifting the Bits to the Left What happens if the bits are shifted to the left by 1 bit position? 1 = 5 Before After = 10 Multiplication By 2 What happens if the bits are shifted to the left by 2 bit positions? 1 = 5 Before After = 20 Multiplication By 4 Shifting the Bits to the Left by n bit positions is multiplication by 2n As long as we have sufficient space to store the bits

Shifting the Bits to the Right What happens if the bits are shifted to the right by 1 bit position? 1 = 38 Before After = 19, r=0 Division By 2 What happens if the bits are shifted to the right by 2 bit positions? 1 = 38 Before After = 9, r=2 Division By 4 Shifting the Bits to the Right by n bit positions is division by 2n The remainder r is the value of the bits that are shifted out