Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Similar documents
Chapter 3: part 3 Binary Subtraction

Digital Fundamentals

CO Computer Architecture and Programming Languages CAPL. Lecture 9

CHW 261: Logic Design

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

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Chapter 4 Arithmetic Functions

Computer Organization

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

EE 109 Unit 6 Binary Arithmetic

Chapter 10 Binary Arithmetics

Chapter 1. Digital Systems and Binary Numbers

D I G I T A L C I R C U I T S E E

Korea University of Technology and Education

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

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

carry in carry 1101 carry carry

COMBINATIONAL LOGIC CIRCUITS

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

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

Chapter 4 Section 2 Operations on Decimals

Digital Fundamentals

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

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

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Number representations

LOGIC CIRCUITS. Kirti P_Didital Design 1

Lecture (02) Operations on numbering systems

Chapter 5: Computer Arithmetic

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

Number Systems Base r

CO212 Lecture 10: Arithmetic & Logical Unit

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

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

Arithmetic and Logical Operations

Module 2: Computer Arithmetic

CS101 Lecture 04: Binary Arithmetic

Numerical Representations On The Computer: Negative And Rational Numbers

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

Numerical Representations On The Computer: Negative And Rational Numbers

INF2270 Spring Philipp Häfliger. Lecture 4: Signed Binaries and Arithmetic

Chapter 4. Combinational Logic

Chapter 1 Review of Number Systems

Number Systems. Both numbers are positive

Digital Systems and Binary Numbers

Chapter 3 Part 2 Combinational Logic Design

Number System. Introduction. Decimal Numbers

Digital Fundamentals

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

COMPUTER ARITHMETIC (Part 1)

Experiment 7 Arithmetic Circuits Design and Implementation

Numeric Encodings Prof. James L. Frankel Harvard University

MC1601 Computer Organization

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

Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

World Inside a Computer is Binary

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals.

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Arithmetic Operations

1. Mark the correct statement(s)

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Principles of Computer Architecture. Chapter 3: Arithmetic

CS/EE1012 INTRODUCTION TO COMPUTER ENGINEERING SPRING 2013 HOMEWORK I. Solve all homework and exam problems as shown in class and sample solutions

Chapter Three. Digital Components

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

Chapter 2: Number Systems

Microcomputers. Outline. Number Systems and Digital Logic Review

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

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

Signed umbers. Sign/Magnitude otation

Digital Systems and Binary Numbers

Chapter 10 - Computer Arithmetic

*Instruction Matters: Purdue Academic Course Transformation. Introduction to Digital System Design. Module 4 Arithmetic and Computer Logic Circuits

CMPE223/CMSE222 Digital Logic Design. Positional representation

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

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Chapter 4 Arithmetic

Floating Point Arithmetic

Part 2,Number Systems Questions

Computer Architecture and Organization: L04: Micro-operations

Number Systems CHAPTER Positional Number Systems

Organisasi Sistem Komputer

Chapter 3: Arithmetic for Computers

Positional Number System

UNIT IV: DATA PATH DESIGN

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

Chapter 3 Part 2 Combinational Logic Design

Arithmetic Operations on Binary Numbers

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

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

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Transcription:

Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous result, the rules are 1 + 0 + 0 = 01 Sum = 1, carry = 0 1 + 0 + 1 = 10 Sum = 0, carry = 1 1 + 1 + 0 = 10 Sum = 0, carry = 1 1 + 1 + 1 = 11 Sum = 1, carry = 1 1

Binary Addition Add the binary numbers 00111 and 10101 and show the equivalent decimal addition. 0 1 1 1 00111 7 10101 21 1 1 1 0 0 = 28 2

Binary Subtraction The rules for binary subtraction are 0-0 = 0 1-1 = 0 1-0 = 1 10-1 = 1 with a borrow of 1 Subtract the binary number 00111 from 10101 and show the equivalent decimal subtraction. 1 1 1 / 10101 / / 21 00111 7 0 1 1 1 0 = 14 3

1 s Complement The 1 s complement of a binary number is just the inverse of the digits. To form the 1 s complement, change all 0 s to 1 s and all 1 s to 0 s. For example, the 1 s complement of 11001010 is 00110101 In digital circuits, the 1 s complement is formed by using inverters: 1 1 0 0 1 0 1 0 0 0 1 1 0 1 0 1 4

2 s Complement The 2 s complement of a binary number is found by adding 1 to the LSB of the 1 s complement. Recall that the 1 s complement of 11001010 is 00110101 (1 s complement) To form the 2 s complement, add 1: +1 1 1 0 0 1 0 1 0 00110110 (2 s complement) 1 0 0 1 1 0 1 0 1 Input bits Adder Output bits (sum) 0 0 1 1 0 1 1 0 Carry in (add 1) 5

Signed Binary Numbers There are several ways to represent signed binary numbers. In all cases, the MSB in a signed number is the sign bit, that tells you if the number is positive or negative. Computers use a modified 2 s complement for signed numbers. Positive numbers are stored in true form (with a 0 for the sign bit) and negative numbers are stored in complement form (with a 1 for the sign bit). For example, the positive number 58 is written using 8-bits as 00111010 (true form). Sign bit Magnitude bits 6

Signed Binary Numbers Negative numbers are written as the 2 s complement of the corresponding positive number. The negative number -58 is written as: -58 = 11000110 (complement form) Sign bit Magnitude bits An easy way to read a signed number that uses this notation is to assign the sign bit a column weight of -128 (for an 8-bit number). Then add the column weights for the 1 s. Assuming that the sign bit = -128, show that 11000110 = -58 as a 2 s complement signed number: Column weights: -128 64 32 16 8 4 2 1. 1 1 0 0 0 1 1 0-128 +64 +4 +2 = -58 7

Arithmetic Operations with Signed Numbers Using the signed number notation with negative numbers in 2 s complement form simplifies addition and subtraction of signed numbers. Rules for addition: Add the two signed numbers. Discard any final carries. The result is in signed form. Examples: 00011110 = +30 00001111 = +15 00101101 = +45 00001110 = +14 11101111 = -17 11111101 = -3 11111111 = -1 11111000 = -8 1 11110111 = -9 Discard carry 8

Arithmetic Operations with Signed Numbers Note that if the number of bits required for the answer is exceeded, overflow will occur. This occurs only if both numbers have the same sign. The overflow will be indicated by an incorrect sign bit. Two examples are: 01000000 = +128 01000001 = +129 10000001 = -126 Discard carry 10000001 = -127 10000001 = -127 100000010 = +2 Wrong! The answer is incorrect and the sign bit has changed. 9

Arithmetic Operations with Signed Numbers Rules for subtraction: 2 s complement the subtrahend and add the numbers. Discard any final carries. The result is in signed form. Repeat the examples done previously, but subtract: - 00011110 00001111 (+30) (+15) 2 s complement subtrahend and add: 00011110 = +30 11110001 = -15 100001111 = +15 00001110 11101111 (+14) (-17) - - 00001110 = +14 00010001 = +17 00011111 = +31 11111111 11111000 (-1) (-8) 11111111 = -1 00001000 = +8 100000111 = +7 Discard carry Discard carry 10

Complements of Binary Numbers 1 s complement Change all 1s to 0s and all 0s to 1s 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 11

Complements of Binary Numbers 2 s complement Find 1 s complement and then add 1 1 0 1 0 1 0 1 0 1 1 s complement 0 1 0 1 0 1 0 1 Input bits Adder Output bits (sum) Carry In (add 1) 2 s complement 0 1 0 1 0 1 1 0 12

Arithmetic Operations with Signed Numbers Addition of Signed Numbers The parts of an addition function are: Augend - The first number Addend - The second number Sum - The result Numbers are always added two at a time. 13

Arithmetic Operations with Signed Numbers Four conditions for adding numbers: 1. Both numbers are positive. 2. A positive number that is larger than a negative number. 3. A negative number that is larger than a positive number. 4. Both numbers are negative. 14

Arithmetic Operations with Signed Signs for Addition Numbers When both numbers are positive, the sum is positive. When the larger number is positive and the smaller is negative, the sum is positive. The carry is discarded. 15

Arithmetic Operations with Signed Signs for Addition Numbers When the larger number is negative and the smaller is positive, the sum is negative (2 s complement form). When both numbers are negative, the sum is negative (2 s complement form). The carry bit is discarded. 16

Examples (8 bit numbers) Add 7 and 4 (both positive) 00000111 7 +00000100 + 4 00001011 11 Add 15 and -6 (positive > negative) Discard carry Add 16 and -24 (negative > positive) Sign bit is negative so negative number in 2 s complement form 00001111 15 +11111010 + -6 1 00001001 9 00010000 16 +11101000 + -24 11111000-8 Add -5 and -9 (both negative) Discard carry 11111011-5 +11110111 + -9 1 11110010-14 17

Overflow Overflow occurs when number of bits in sum exceeds number of bits in addend or augend. Overflow is indicated by the wrong sign. Occurs only when both numbers are positive or both numbers are negative Sign Incorrect Magnitude Incorrect 01111101 126 + 00111010 + 58 10110111 183 18

Arithmetic Operations with Signed Numbers Subtraction of Signed Numbers The parts of a subtraction function are: Minuend - The first number Subtrahend - The second number Difference - The result Subtraction is addition with the sign of the subtrahend changed. 19

Arithmetic Operations with Signed Subtraction Numbers The sign of a positive or negative binary number is changed by taking its 2 s complement To subtract two signed numbers, take the 2 s complement of the subtrahend and add. Discard any final carry bit. 20

Subtraction Examples Find 8 minus 3. Discard carry Find 12 minus -9. Find -25 minus 19. Discard carry Find -120 minus -30. 00001000 8 +11111101-3 1 00000101 5 00001100 12 +00001001 - -9 00010101 21 11100111-25 +11101101-19 1 11010100-44 10001000-120 +00011110 - -30 10100110-90 Minuend Subtrahend Difference 21