Chapter3 Fixed Point Representation

Slides:



Advertisements
Similar presentations
CENG536 Computer Engineering department Çankaya University.
Advertisements

Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Number Systems Standard positional representation of numbers:
School of Computer Science G51CSA 1 Computer Arithmetic.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
Data Representation – Binary Numbers
Computer Arithmetic Nizamettin AYDIN
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computer Architecture
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Operations on Bits Arithmetic Operations Logic Operations
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.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
IT1004: Data Representation and Organization Negative number representation.
Exam1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Integer Operations Computer Organization and Assembly Language: Module 5.
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.
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
Lecture 4: Digital Systems & Binary Numbers (4)
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 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Numbers Dr. Mohsen NASRI College of Computer and Information Sciences, Majmaah University, Al Majmaah
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
CHAPTER 5: Representing Numerical Data
Floating Point Numbers
Floating Point Representations
Dr.Faisal Alzyoud 2/20/2018 Binary Arithmetic.
Prof. Sin-Min Lee Department of Computer Science
A brief comparison of integer and double representation
Chapter 4 Operations on Bits.
Dr. Clincy Professor of CS
A Level Computing Component 2
William Stallings Computer Organization and Architecture 7th Edition
Dr. Clincy Professor of CS
Dr. Clincy Professor of CS
Number Representations
Data Representation Data Types Complements Fixed Point Representation
EEL 3705 / 3705L Digital Logic Design
How to represent real numbers
How to represent real numbers
EE207: Digital Systems I, Semester I 2003/2004
ECEG-3202 Computer Architecture and Organization
Unit 18: Computational Thinking
How are negative and rational numbers represented on the computer?
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Dr. Clincy Professor of CS
CPS120: Introduction to Computer Science
Chapter 8 Computer Arithmetic
Binary to Decimal Conversion
ECE 331 – Digital System Design
Floating Point Numbers
Data Binary Arithmetic.
Chapter 1 (Part c) Digital Systems and Binary Numbers
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Number Representations
1.6) Storing Integer: 1.7) storing fraction:
Two’s Complement & Binary Arithmetic
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009

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

X-Y X= 1010100 2’s com. of Y= 0111101 Sum= 10010001 Answer= 0010001

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

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: signed magnitude, 1’s complement, and 2’s complement

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

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. 000011002 = 1210 Sign bit Magnitude 111100112 = -1210 Sign bit 1’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. 000011002 = 1210 Sign bit Magnitude 111101002 = -1210 Sign bit 2’s complement

Sign addition in 2’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: + 6 00000110 - 6 11111010 +13 00001101 +13 00001101 +19 00010011 +7 00000111 +6 00000110 -6 11111010 -13 11110011 -13 11110011 -7 11111001 -19 11101101 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. 9

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 11111010 - 11110011. The subtraction is changed to addition by taking the 2’s complement of the subtrahend (-13) to give (+13). In binary this is 11111010 + 00001101 = 100000111. Removing the end carry, we obtain the correct answer 00000111 (+ 7).

Overflow The detection of an overflow after the addition of two binary numbers depends on whether the considered numbers are signed or unsigned. When two unsigned numbers are added, an overflow is detected from the end carry out of the most significant position. In the case of signed numbers, the leftmost bit always represents the sign, and negative numbers are in 2’s complement form. When two signed numbers are added, the sign bit is treated as part of the number and the end carry does not indicate an overflow.

Overflow Overflow example: +70 0 1000110 -70 1 0111010 +70 0 1000110 -70 1 0111010 +80 0 1010000 -80 1 0110000 = +150 1 0010110 =-150 0 1101010

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.

Floating-Point Representation + 6132.789 is represented in floating-point with a fraction and an exponent as follows: Fraction Exponent +0.6132789 +04 Scientific notation : + 0.6132789  10+4

Floating-Point Representation Floating point is always interpreted as: m  re Floating point binary number uses base 2 for the exponent. For example: Binary number +1001.11 Fraction(8 bits) Exponent (6 bits) 01001110 000100 The fraction has a 0 in the leftmost position to denote positive. m  2e = + (.1001110)2  2+4

Floating-Point Representation A floating-point number is said to be normalized if the most significant digit of the mantissa is nonzero. For example: (1)   350 is normalized but 00035 is not. (2)   The 8-bit binary number 00011010 is not. It can be normalized by shifting to obtain 11010000. The three shifts multiply the number by 23=8. To keep the same value for floating-point number, the exponent must be subtracted by 3.

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 sign sign EXP EXP Significant Convert the following number;37.75 into floating point format to fit in 32 bit register. Convert the number from decimal into binary 100101.11 Normalize all digits including the fraction to determine the exponent. 1.0010111 x 25 1 sign sign EXP EXP Significant