ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:

Slides:



Advertisements
Similar presentations
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
Advertisements

HEXADECIMAL NUMBERS Code
Computer Engineering (Logic Circuits) Dr. Tamer Samy Gaafar Lec. # 2
ECE 331 – Digital System Design
EECS Components and Design Techniques for Digital Systems Lec 17 – Addition, Subtraction, and Negative Numbers David Culler Electrical Engineering.
Assembly Language and Computer Architecture Using C++ and Java
Fixed-Point Arithmetics: Part I
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Assembly Language and Computer Architecture Using C++ and Java
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Lecture 8 Arithmetic Logic Circuits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
ECE 301 – Digital Electronics
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)
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Number Systems Lecture 02.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
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.
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
Representing Integer Data Book : Chapter ( Subject has no point !! ) A99ACF.
Basic Arithmetic (adding and subtracting)
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Chapter # 5: Arithmetic Circuits
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Basic Arithmetic (adding and subtracting)
46 Number Systems Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs Display: Seven segment displays Inputs: Switches.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
Operations on Bits Arithmetic Operations Logic Operations
CS Data representation 1 Ch. 2.1 Data Representation Unsigned and Signed Integers – representation, addition, subtraction.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
By Jariya Phongsai A two's-complement system is a system in which negative numbers are represented by the two's complement of the absolute value; this.
08 ARTH Page 1 ECEn/CS 224 Number Representation and Binary Arithmetic.
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
69 Decimal (Base 10) Numbers n Positional system - each digit position has a value n 2534 = 2*1, * *10 + 4*1 n Alternate view: Digit position.
CPS3340 Computer Architecture Fall Semester, 2013
Introduction * Binary numbers are represented with a separate sign bit along with the magnitude. * For example, in an 8-bit binary number, the MSB is.
IT1004: Data Representation and Organization Negative number representation.
Registers and Binary Arithmetic Prof. Sirer CS 316 Cornell University.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
Integer Operations Computer Organization and Assembly Language: Module 5.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
Electrical Engineering Engineering the Future Digital Circuits Fundamentals Hands-on Full-Adder Simulation (afternoon)
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Lecture 4: Digital Systems & Binary Numbers (4)
1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.
Addition and Subtraction
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
Dr. Clincy Professor of CS
Arithmetic Circuits (Part I) Randy H
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Dr. Clincy Professor of CS
Presentation transcript:

ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude: 0 (000 2 ) thru 7 (111 2 ) Number range for n bits = ± (2 n -1) Two representations for 0

ELEC353 S. al Zahir UBC Sign-Magnitude Representations Addition and Subtraction of Numbers (-3) Both operands have same sign: Result sign bit is the same as the operands' sign Operands have different sign: Operation is subtraction. Sign of result depends on sign of number with the larger magnitude R = X-Y if X>Y subtract |Y| from |X|, sign(R) = sign(X). if X<Y subtract |X| from Y|, sign(R) = sign(Y).

ELEC353 S. al Zahir UBC Ones Complement Representation Disadvantages of Sign-Magnitude Representation: Cumbersome addition/subtraction Must compare magnitudes to determine sign of result Ones Complement Representation: Definitions N is positive number, then N is its negative 1's complement N = (2 - 1) - N n Example: 1's complement of 7 = -7 in 1's comp. Shortcut method: simply compute bit wise complement > 1000 = -1 in 1's comp. 2 = = = =

ELEC353 S. al Zahir UBC Ones Complement Representation Subtraction implemented by addition using 1's complement Still two representations of 0! This causes some problems Some complexities in addition

ELEC353 S. al Zahir UBC Two Complement Representations Only one representation for 0 One more negative number than positive number Similar to 1's complement except shifted by one position clockwise N* =2’s comp of N N* = 2 n - N

ELEC353 S. al Zahir UBC Two Complement Representations N* = 2 - N n Example: Twos complement of 7 2 = = = repr. of -7 Example: Twos complement of = = = repr. of 7 4 sub Shortcut method: Twos complement = bitwise complement > > 1001 (representation of -7) > > 0111 (representation of 7)

ELEC353 S. al Zahir UBC Number Systems Ones Complement Calculations (-3) End around carry Add carry-out of sign-bit to LSB (assuming no overflow) Method: 1- Add two n-bit numbers starting from LSB 2- If there is an end carry (into position n+1), then remove carry and add a 1 to the LSB (end-around carry).

ELEC353 S. al Zahir UBC Number Systems Ones Complement Calculations Why does end-around carry work? Its equivalent to subtracting 2 n and adding 1 (i.e. performing -2 n +1) Case 1 (M > N): S = M - N = M + N = M + (2 n N) = (M - N) + 2 n - 1 After end-around carry SUM = S -2 n +1= (M - N) + 2 n n + 1 = M - N Case 2 (-M-N, where M + N < 2 n-1); -M + (-N) = M + N = (2 n - M - 1) + (2 n - N - 1) = 2 n + [2 n (M + N)] - 1 after end around carry: = 2 n (M + N) this is the correct form for representing -(M + N) in 1's complement -4 + (-3)

ELEC353 S. al Zahir UBC Number Systems Twos Complement Calculations (-3) Overflow condition for 2’s complement: if carry into sign-bit differs from carry out of sign-bit then the results is an overflow Simpler addition scheme makes twos complement the most common choice for integer number systems within digital systems Method (If no overflow): 1- Add two n-bit numbers starting from LSB 2- Discard the carry out of the sign-bit.

ELEC353 S. al Zahir UBC Number Systems Twos Complement Calculations Discarding End Carry: is equivalent to subtracting 2 n Case 1 (-M+N, where N > M): S = -M + N = M* + N = (2 n - M) + N = 2 n - (N - M) After discarding end carry SUM = S -2 n = 2 n - (N - M) - 2 n = N - M Case 2 (-M + (-N), where M + N < 2 n-1 ): S = -M + (-N) = M* + N* = (2 n - M) + (2 n - N) = 2 n - (M+N) + 2 n After discarding end carry SUM = S -2 n = 2 n - (M+N) + 2 n - 2 n = 2 n - (M+N) = (M+N)* -4 + (-3)

ELEC353 S. al Zahir UBC Overflow Conditions (2’s Complement) Overflow occurs when the result of adding two positive (or two negative) n-bit numbers requires more than n bits to be expressed correctly. Overflow indications: Adding two positive numbers results in a negative number Adding two negative numbers results in a positive number = =

ELEC353 S. al Zahir UBC Overflow Examples Overflow No overflow Simple Check: Overflow occurs when carry into sign-bit does not equal the carry out of the sign-bit.

ELEC353 S. al Zahir UBC Logic Circuits for Binary Addition Half Adder Circuit Half-adder Schematic With twos-complement numbers, adders can perform both addition and subtraction.

ELEC353 S. al Zahir UBC Logic Circuits for Binary Addition Full Adder Cascaded Multi-bit Adder usually interested in adding more than two bits this motivates the need for the full adder