Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.

Slides:



Advertisements
Similar presentations
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Advertisements

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:
COE 202: Digital Logic Design Signed Numbers
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Arithmetic See: P&H Chapter 3.1-3, C.5-6.
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
Computer Organization & Programming Chapter2 Number Representation and Logic Operations.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CENG 311 Machine Representation/Numbers
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Dale & Lewis Chapter 3 Data Representation. Data and computers Everything inside a computer is stored as patterns of 0s and 1s Numbers, text, audio, video,
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic Part 2.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
Number Representation
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.
Sep 29, 2004Subtraction (lvk)1 Negative Numbers and Subtraction The adders we designed can add only non-negative numbers – If we can represent negative.
08 ARTH Page 1 ECEn/CS 224 Number Representation and Binary Arithmetic.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
CPS3340 Computer Architecture Fall Semester, 2013
2's Complement Arithmetic
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
Computer Organization 1 Data Representation Negative Integers.
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
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)
Representing Positive and Negative Numbers
Department of Computer Science Georgia State University
Computer Architecture & Operations I
Negative Numbers and Subtraction
Chapter 4 Operations on Bits.
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Negative Binary Numbers
Integers’ Representation. Binary Addition. Two's Complement.
Computer Science 210 Computer Organization
Data Representation in Computer Systems
CSCI206 - Computer Organization & Programming
Addition of Signed Numbers
Section 2: Integer & Floating Point Numbers
Computer Architecture & Operations I
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Negative Binary Numbers
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
ECE 2110: Introduction to Digital Systems
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Computer Science 210 Computer Organization
COMPLEMENTS Complements are used in digital computers for simplifying the subtraction operations and for logical manipulation. There are two types of complements.
INTEGER RULES Positives & negatives.
Data Representation in Computer Systems
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
1.6) Storing Integer:.
EEL 3705 / 3705L Digital Logic Design
Unit 18: Computational Thinking
COMS 161 Introduction to Computing
Dr. Clincy Professor of CS
Comparing integers.
Algorithms for Integer Arithmetic
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic
INTEGER RULES Positives & negatives.
CSC 220: Computer Organization Signed Number Representation
COMS 361 Computer Organization
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Two’s Complement & Binary Arithmetic
Today Binary addition Representing negative numbers 2.
Presentation transcript:

Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative by putting a negative sign in front of it: 1410 negated = -1410 You might hope to do the same with binary: 0000 1110 negated = -0000 1110 Unfortunately, you can't put a negative sign in front of a bit pattern in computer memory. Memory holds only patterns of 0's and 1's.

Sign-Magnitude Representation There are many schemes for representing negative integers with patterns of bits. One scheme is sign-magnitude. It uses one bit (usually leftmost) to indicate the sign. "0" indicates a positive integer and "1" indicates a negative integer. The rest of the bits are used for the magnitude of the number. So -1410 is represented as: 1000 1110 7 last bits are magnitude --- ---- The sign "1" means negative, ”0”-positive

Sign Magnitude Pros & Cons Advantages: It works well for representing positive and negative integers. Disadvantages: One pattern corresponds to "minus zero", 1000 Another corresponds to "plus zero", 0000 Computations are not simple.

Sign magnitude calculations many sign and magnitude checks If the signs are the same, it must add the magnitudes and give the result the same sign. If the signs are different, it must compare the magnitudes subtract the smaller from the larger and give the result the sign of the larger. All of these “ifs”, “adds”, “subtracts”, and “compares” translate into a lot of logic-circuit complexity. Adders for complement number systems are much simpler.

Sign magnitude vs Complements While the signed-magnitude system negates a number by changing its sign a complement number system negates by taking its complement. In a Complement number system two numbers can be added or subtracted directly without the sign and magnitude checks.

One’s complement The negative numbers are represented by the patterns derived from the positive numbers. Adding the negative and positive numbers with the same absolute value results the pattern of all ones. Negative = 2N – 1 – Positive

One’s complement pros & cons Advantages: In a Complement number system two numbers can be added or subtracted directly without the sign and magnitude checks. Disadvantages: Arithmetic still a somewhat complicated. Still two zeros 0x0000 = +0ten 0x1111 = -0ten Although used for a while on some computer products, one’s complement was eventually abandoned because another solution was better.