Computer Science 210 Computer Organization

Slides:



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

Binary Representation Introduction to Computer Science and Programming I Chris Schmidt.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Representations Example: Numbers –145 –CVL – –91 –
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Two’s Complement 1.As an action: (Assume the starting value is 1011) 1.Flip the bits from the starting value => Add one to get the answer.
Computer Science 101 Number Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
Number Systems Computer Science 210 Computer Organization.
Computer Science 101 Introduction to Programming with Sounds.
Computer Systems 1 Fundamentals of Computing Negative Binary.
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.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 29, 2004 Lecture Number: 26.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic Part 2.
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.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
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.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
Number Representation (Part 2) Computer Architecture (Fall 2006)
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
973cs111_add_posneg.ppt Integers Whole numbers Do NOT contain decimal points (as in money) 43,689 is an integer 43, is NOT an integer (it is floating.
ECE 2110: Introduction to Digital Systems Signed Number Conversions.
Representing Positive and Negative Numbers
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
1 Chapter 1: Basic Concepts Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine 9/6/2003.
Topic: Binary Encoding – Part 2
Design of Digital Circuits Reading: Binary Numbers
David Kauchak CS 52 – Spring 2017
Addition and Subtraction
Array multiplier TU/e Processor Design 5Z032.
Binary -ve and +ve numbers!.
Negative Integers Unsigned binary representation can not be used to represent negative numbers. With paper and pencil arithmetic, a number is made negative.
A brief comparison of integer and double representation
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Negative Binary Numbers
Integers’ Representation. Binary Addition. Two's Complement.
Introduction To Computer Science
Computer Science 210 Computer Organization
Data Representation Integers
Negative Binary Numbers
CSE 102 Introduction to Computer Engineering
Binary Addition & Subtraction
ECE 2110: Introduction to Digital Systems
Number Representations
Data Representation in Computer Systems
1.6) Storing Integer:.
Unit 18: Computational Thinking
COMS 161 Introduction to Computing
Number Representation
CPS120: Introduction to Computer Science
Decimal and binary representation systems
CSC 220: Computer Organization Signed Number Representation
COMS 361 Computer Organization
Chapter3 Fixed Point Representation
Activity 2 How is the word length of a two’s complement representation changed without affecting its value? In this activity, we are going to study how.
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
Number Representations
Two’s Complement & Binary Arithmetic
Today Binary addition Representing negative numbers 2.
Presentation transcript:

Computer Science 210 Computer Organization Number Systems Signed Integers

Negatives: Sign-Magnitude With a fixed number of bits, say N The leftmost bit is used to give the sign 0 for positive number 1 for negative number The other N-1 bits are for the magnitude Example: -25 with 8 bit numbers Sign: 1 since negative Magnitude: 11001 for 25 8-bit result: 10011001 Note: This would be 153 as a positive.

Ranges for N-bit numbers Unsigned (positive) 0000…00 or 0 1111…11 which is 2N-1 For N=8, 0 - 255 Sign-magnitude 1111…11 which is -(2N-1-1) 0111…11 which is 2N-1-1 For N=8, -127 to 127 2’s Complement 1000…00 which is -2N-1 0111…11 which is 2N-1 - 1 For N=8, -128 to 127

Sign-Magnitude: Pros and Cons Easy to comprehend Easy to convert Con: Addition complicated (expensive) If signs same then … else if positive part larger … Two representations of 0

Negatives: Two’s complement With N bit numbers, to compute negative Invert all the bits Add 1 Example: -25 in 8-bit two’s complement 25  00011001 Invert bits: 11100110 Add 1: 1 11100111

2’s Complement: Pros and Cons Not so easy to comprehend Human must convert negative to identify Pro: Addition is exactly same as for positives No additional hardware for negatives, and subtraction. One representation of 0

2’s Complement: Examples Compute negative of -25 (8-bits) We found -25 to be 11100111 Invert bits: 00011000 Add 1: 00011001 Recognize this as 25 in binary Add -25 and 37 (8-bits) 11100111 (-25) + 00100101 ( 37) (1)00001100 Recognize as 12

Facts about 2’s Complement Leftmost bit still tells whether number is positive or negative as with sign-magnitude 2’s complement is same as sign magnitude for positives

2’s complement to decimal (examples) Assume 8-bit 2’s complement: X = 11011001 -X = 00100110 + 1 = 00100111 = 32+4+2+1 = 39 (decimal) So, X = -39 X = 01011001 Since X is positive, we have X = 64+16+8+1 = 89