Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.

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 Arithmetic Binary addition Binary subtraction
James Tam Numerical Representations On The Computer: Negative And Rational Numbers How are negative and rational numbers represented on the computer? How.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
Signed Numbers.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
Operations on data CHAPTER 4.
School of Computer Science G51CSA 1 Computer Arithmetic.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
Computer Systems 1 Fundamentals of Computing Negative Binary.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
IT253: Computer Organization
Computer Architecture
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
CSC 221 Computer Organization and Assembly Language
Operations on Bits Arithmetic Operations Logic Operations
Exam1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Chapter 3 Complements Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Number Systems & Operations
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
IT1004: Data Representation and Organization Negative number representation.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
Exam1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Numbers in Computers.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 8 Dr. Shi Dept. of Electrical and Computer Engineering.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
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.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Lecture 4: Digital Systems & Binary Numbers (4)
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 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Prof. Sin-Min Lee Department of Computer Science
Data Representation Data Types Complements Fixed Point Representation
CPS120: Introduction to Computer Science
Chapter3 Fixed Point Representation
Chapter 1 (Part c) Digital Systems and Binary Numbers
Presentation transcript:

Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010

Outline Subtraction of Unsigned Numbers using r’s complement How To Represent Signed Numbers Floating-Point Representation

Subtraction of Unsigned Numbers using r’s complement (1) if M  N, ignore the carry without taking complement of sum. (2) if M < N, take the r’s complement of sum and place negative sign in front of sum. The answer is negative.

Example 1 (Decimal unsigned numbers), perform the subtraction = M > N : “Case 1” “Do not take complement of sum and discard carry” The 10’s complement of is Therefore: M = ’s complement of N = Sum= Discard end carry 10 5 = Answer = 59282no complement

Example 2; Now consider an example with M <N. The subtraction produces negative Using the procedure with complements, we have M = ’s complement of N = Sum = Take 10’s complement of Sum = The number is : Place negative sign in front of the number:-59282

Subtract by Summation Subtraction with complement is done with binary numbers in a similar way. Using two binary numbers X= and Y= We perform X-Y and Y-X

X-Y X= ’s com. of Y= Sum= Answer=

Y-X Y= ’s com. of X= Sum= There’s no end carry: answer is negative (2’s complement of )

Outline Subtraction of Unsigned Numbers using r’s complement How To Represent Signed Numbers Floating-Point Representation

How To Represent Signed Numbers Plus and minus signs used for decimal numbers: 25 (or +25), -16, etc.. For computers, it is desirable to represent everything as bits. Three types of signed binary number representations: 1. signed magnitude, 2. 1’s complement, and 3. 2’s complement

1. signed magnitude In each case: left-most bit indicates sign: positive (0) or negative (1). Consider 1. signed magnitude: = Sign bitMagnitude = Sign bitMagnitude

2. One’s Complement Representation The one’s complement of a binary number involves inverting all bits. To find negative of 1’s complement number take the 1’s complement of whole number including the sign bit.To find negative of 1’s complement number take the 1’s complement of whole number including the sign bit = Sign bitMagnitude = Sign bit1’complement

3. Two’s Complement Representation The two’s complement of a binary number involves inverting all bits and adding 1. To find the negative of a signed number take the 2’s the 2’s complement of the positive number including the sign bit = Sign bitMagnitude = Sign bit2’s complement

The rule for addition is add the two numbers, including their sign bits, and discard any carry out of the sign (leftmost) bit position. Numerical examples for addition are shown below. Example: In each of the four cases, the operation performed is always addition, including the sign bits. Only one rule for addition, no separate treatment of subtraction. Negative numbers are always represented in 2’s complement. Sign addition in 2’s complement

Arithmetic Subtraction A subtraction operation can be changed to an addition operation if the sign of the subtrahend is changed. (±A) - (+B) = (±A) + (-B) (±A) - (-B) = (±A) + (+B)

Arithmetic Subtraction Consider the subtraction of (-6) - (-13) = +7. In binary with eight bits this is written as The subtraction is changed to addition by taking the 2’s complement of the subtrahend (-13) to give (+13). In binary this is = Removing the end carry, we obtain the correct answer (+ 7).

Overflow Overflow example: = =

Overflow An overflow cannot occur after an addition if one number is positive and the other is negative, since adding a positive number to a negative number produces a result that is smaller than the larger of the two original numbers. An overflow may occur if the two numbers added are both either positive or negative.

Outline Subtraction of Unsigned Numbers using r’s complement How To Represent Signed Numbers Floating-Point Representation

is represented in floating-point with a fraction and an exponent as follows: Fraction Exponent Scientific notation :  10 +4

Floating-Point Representation 32-bit floating point format. Leftmost bit = sign bit (0 positive or 1 negative). Exponent in the next 8 bits. Use a biased representation. Final portion of word (23 bits in this example) is the significand (sometimes called mantissa).

Example Convert the following number;37.75 into floating point format to fit in 32 bit register. Convert the number from decimal into binary Normalize all digits including the fraction to determine the exponent x sign EXP Significant

Outline Subtraction of Unsigned Numbers using r’s complement How To Represent Signed Numbers Floating-Point Representation