1 Integer Representations V1.0 (22/10/2005). 2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s.

Slides:



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

COE 202: Digital Logic Design Signed Numbers
Addition of two binary numbers = = = = 39.
Arithmetic & Logic Unit Does the calculations Everything else in the computer is there to service this unit Handles integers May handle floating point.
King Fahd University of Petroleum and Minerals
1 Lecture 3 Bit Operations Floating Point – 32 bits or 64 bits 1.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
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.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
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.
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.
Adding Integers. Adding Integers with the Same Sign Add the absolute values. The sum will have the same sign as the addends. Example 1 Find –2 + (-3)
Number Systems Computer Science 210 Computer Organization.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary numbers and arithmetic. ADDITION Addition (decimal)
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
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.
Lecture 5.
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.
Number Systems Part 2 Numerical Overflow Right and Left Shifts Storage Methods Subtraction Ranges.
Basic Arithmetic (adding and subtracting)
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computer Architecture
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.
9.4 FLOATING-POINT REPRESENTATION
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.
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)
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Positional Number Systems
Number Representation
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Operations on Bits Arithmetic Operations Logic Operations
Floating Point Arithmetic
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
Lecture 2 Binary Arithmetic Topics Terminology Fractions Base-r to decimal Unsigned Integers Signed magnitude Two’s complement August 26, 2003 CSCE 211.
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.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
IT1004: Data Representation and Organization Negative number representation.
Integers’ Representation. Binary Addition. Two's Complement. Unsigned number representation Binary Addition, Subtraction. Overflow of unsigned numbers.
ECE 171 Digital Circuits Chapter 2 Binary Arithmetic Herbert G. Mayer, PSU Status 1/14/2016 Copied with Permission from prof. Mark PSU ECE.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
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.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Computer Organization 1 Data Representation Negative Integers.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
Binary Arithmetic James A. Rome Tennessee Governor's Academy August 2010.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
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:
David Kauchak CS 52 – Spring 2017
Computer Science 210 Computer Organization
SAME SIGNS JUST ADD !! ADDITION OF INTEGERS = (-2) = -10
Computer Science 210 Computer Organization
1.6) Storing Integer:.
Unit 18: Computational Thinking
CPS120: Introduction to Computer Science
COMS 361 Computer Organization
Chapter3 Fixed Point Representation
Two’s Complement & Binary Arithmetic
Presentation transcript:

1 Integer Representations V1.0 (22/10/2005)

2 Integer Representations  Unsigned integer  Signed integer  Sign and magnitude  Complements  One’s complement  Two’s complement  Overflow

3 Unsigned integer Represented as binary number 8-bits Unsigned integer representation  0 as  1 as  …  254 as  255 as

4 Unsigned integer arithmetic Same as binary arithmetic For addition, the sum cannot exceed the maximum integer that can be represented For subtraction, the difference must be greater than or equal to 0

5 Signed integer Fixed bits => can only represent fixed value of integer Signed integer  Half of the range negative number  Half of the range positive number

6 sign and magnitude Use the left most bit for sign ( 0 as positive ;1 as negative) Other bits for magnitude For a 8-bit number

7 Addition of sign and magnitude Same sign  Add the magnitude  The sum cannot use the sign bit  append the sign bit Different sign (N: negative number, P: positive number)  Turn the N to positive (absolute value of N, abs (N) )  If the abs (N) greater than P Sign bit is 1 (negative) Magnitude is difference of abs (N) - P  If the abs (N) less than P Sign bit is 0 (positive) Magnitude is the difference of P-abs (N)

8 Subtraction of sign and magnitude Subtract a positive number  Turn the positive number to negative  Add the magnitude of the two number Subtract a negative number  turn the negative number to positive  add up magnitude of the two number

9 Complements (one's complement) If left-most bit is 0, the number is positive; else it is negative To find the negative representation, find its positive representation, then perform one's complement one's complement means subtract number with all 1 with that number For 8-bit number Negative of : – = Same as reversing the bits

10 Complements (arithmetic with one’s complement) Subtract positive number  turn the positive number to negative  add up magnitude of the two number subtract negative number  turn the negative number to positive  add up magnitude of the two number Addition  Same as binary addition  For any round-up, add 1 to the answer if absolute sum of two same-signed number is different from magnitude sum, overflow occurs

11 Complements (two's complement) If left-most bit is 0, the number is positive; else it is negative To find the negative representation, find its positive representation, then perform one's complement, then add 1 For 8-bit number Negative of : – =

12 Complements (arithmetic with two's complement) Subtract positive number  turn the positive number to negative  add up magnitude of the two number subtract negative number  turn the negative number to positive  add up magnitude of the two number Addition  Same as binary addition if absolute sum of two same-signed number is different from magnitude sum, overflow occurs

13 overflow For both positive and negative numbers, add the absolute value of the minimum negative number, and represent it as binary number For 8-bit number, it can represent up 256 numbers For signed representation, have 128 positive number and 127 negative number Minimum negative number is -127 For all number represented in this format, add 127 to the number, and represent it as binary number

14 arithmetic of overflow Subtract positive number  turn the positive number to negative  add up magnitude of the two number subtract negative number  turn the negative number to positive  add up magnitude of the two number Addition  Same as binary addition if absolute sum of two same-signed number is different from magnitude sum, overflow occurs