1 Positive numbers are well understood An n-bit number represents numbers from 0 to 2 n -1 n+m bits can be used to represent n-bit integer and m-bit fraction.

Slides:



Advertisements
Similar presentations
Lecture no 6. Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P)
Advertisements

Representing Numbers: Integers
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
COE 202: Digital Logic Design Signed Numbers
ECE 331 – Digital System Design
Assembly Language and Computer Architecture Using C++ and Java
Signed Numbers.
Assembly Language and Computer Architecture Using C++ and Java
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
ECE 331 – Digital System Design
ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
9/15/09 - L15 Decoders, Multiplexers Copyright Joanne DeGroat, ECE, OSU1 Binary additon & subtraction.
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.
Introduction to Number Systems
© 2010 Kettering University, All rights reserved..
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
NEGATIVE BINARY NUMBER – Digital Circuit 1 Choopan Rattanapoka.
Computer Systems 1 Fundamentals of Computing Negative Binary.
Computer Arithmetic Nizamettin AYDIN
BINARY ARITHMETIC Binary arithmetic is essential in all digital computers and in many other types of digital systems.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
CPS120: Introduction to Computer Science Computer Math: Signed Numbers.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
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.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
ECE 331 – Digital System Design
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
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
Microcomputers I - Electrical and Computer Engineering Dept. at Kettering.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Number Systems & Operations
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
1 Understand the examples again Overflow –When two positive numbers added together or a negative number subtracted from a positive number yields negative.
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
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
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.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
2's Complement Arithmetic
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
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)
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
Lecture 2 Topics Binary Arithmetic (Unsigned binary operands)
Digital Logic & Design Lecture 02.
1.6) Storing Integer:.
Unit 18: Computational Thinking
C1 Number systems.
How are negative and rational numbers represented on the computer?
CPS120: Introduction to Computer Science
Binary to Decimal Conversion
ECE 331 – Digital System Design
Lecture No.5.
Chapter 1 (Part c) Digital Systems and Binary Numbers
Two’s Complement & Binary Arithmetic
Presentation transcript:

1 Positive numbers are well understood An n-bit number represents numbers from 0 to 2 n -1 n+m bits can be used to represent n-bit integer and m-bit fraction of a number However negative numbers cause another problem In all solutions, one bit is needed to represent the sign, + or - MSB can be used for that purpose, i.e., represent sign Remaining bits can be interpreted differently –They can represent magnitude as a positive number –They can be complemented (represent 0 by 1 and 1 by 0) –Or manipulate in some other way Signed numbers

2 Sign and Magnitude –Out of n bits, one is reserved for sign –Remaining bits represent the value of number as positive –It is equivalent of representing it as 1’s Complement –Convert the positive of number as a binary string –Then complement every bit (replace 1 by 0 and 0 by 1) –This is equivalent of having the weight of MSB as -(2 n-1 -1) 2’s Complement –Convert the positive of number as a binary string –Complement every bit (replace 1 by 0 and 0 by 1) and add 1 –This is equivalent of having the weight of MSB as -2 n-1 Interpretation

3 Sign Magnitude, 1’s, and 2’s complement

4 We use 2’s complement as it makes arithmetic (add/sub) simple n-bits uses only n-1 bits to store the value Largest positive value is 2 n-1 -1 Largest negative value is -2 n-1 For n=4, these values are +7 and -8 For n=8, these values are +127 and -128 If we need larger or smaller values to be stored, we have problem -- leads to overflow and underflow For MULT/DIV sign and magnitude is better –But we cannot keep switching Maximum and Minimum values in n-bits

5 ADD and SUB are fundamental Adding one digit to another gives result(R) and carry(C) bit Subtracting a digit from another gives result(R) and borrow(B) Examples of adding/subtracting two digits A B CR Add/sub of two digits with carry/borrow also gives two digit That is adding/subtracting two digits with carry/borrow C/B A B CR Computer Arithmetic

6 Follow rules of decimal arithmetic Add carry to/sub borrow from the next digit In 2’s complement, if we simply add or subtract without regard to sign, we get correct result if there is no overflow/underflow Examples C/B A B Res CorrCorrOverUnderCorrCorrOverUnder ADD/SUB with more than one bit