FAMU-FSU College of Engineering 1 Computer Architecture EEL 4713/5764, Spring 2006 Dr. Michael Frank Module #9 – Number Representations.

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider.
CHAPTER 2 Number Systems, Operations, and Codes
Assembly Language and Computer Architecture Using C++ and Java
Number Systems Standard positional representation of numbers:
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
Assembly Language and Computer Architecture Using C++ and Java
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Jan. 2011Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Number Systems Lecture 02.
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.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Ch. 2 Floating Point Numbers
Computer Organization and Architecture Computer Arithmetic Chapter 9.
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.
#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.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Data Representation and Computer Arithmetic
ECE232: Hardware Organization and Design
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
9.4 FLOATING-POINT REPRESENTATION
Number Representation Part 1 Fixed-Radix Unsigned Representations ECE 645: Lecture 1.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
FAMU-FSU College of Engineering 1 Part III The Arithmetic/Logic Unit.
Numbers in Computers.
Number Representation Part 1 ECE 645: Lecture 4. Required Reading Chapter 1, Numbers and Arithmetic, Sections Chapter 2, Representing Signed Numbers.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
1. 2 Copyright  2005 by Oxford University Press, Inc. Computer Architecture Parhami3 Figure 9.1 Schematic representation of 4-bit code for integers.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Positional Number Systems In a general radix-r positional system, with fixed word width k, a number is represented by a string of k digits.
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.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
William Stallings Computer Organization and Architecture 8th Edition
Part III The Arithmetic/Logic Unit
Lecture 9: Floating Point
Topic 3d Representation of Real Numbers
EEL 3705 / 3705L Digital Logic Design
ECEG-3202 Computer Architecture and Organization
Topic 3d Representation of Real Numbers
Presentation transcript:

FAMU-FSU College of Engineering 1 Computer Architecture EEL 4713/5764, Spring 2006 Dr. Michael Frank Module #9 – Number Representations

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 2 Part III The Arithmetic/Logic Unit

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 3 III The Arithmetic/Logic Unit Topics in This Part Chapter 9 Number Representation Chapter 10 Adders and Simple ALUs Chapter 11 Multipliers and Dividers Chapter 12 Floating-Point Arithmetic Overview of computer arithmetic and ALU design: Review representation methods for signed integers Discuss algorithms & hardware for arithmetic ops Consider floating-point representation & arithmetic

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 4 9 Number Representation Arguably the most important topic in computer arithmetic: Affects system compatibility and ease of arithmetic Two’s complement, flp, and unconventional methods Topics in This Chapter 9.1 Positional Number Systems 9.2 Digit Sets and Encodings 9.3 Number-Radix Conversion 9.4 Signed Integers 9.5 Fixed-Point Numbers 9.6 Floating-Point Numbers

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Positional Number Systems Representations of natural numbers {0, 1, 2, 3, …} ||||| ||||| ||||| ||||| ||||| ||sticks or unary code 27radix-10 or decimal code 11011radix-2 or binary code XXVII Roman numerals Fixed-radix positional representation with k digits Value of a number: x = (x k–1 x k–2... x 1 x 0 ) r =  x i r i For example: 27 = (11011) two = (1  2 4 ) + (1  2 3 ) + (0  2 2 ) + (1  2 1 ) + (1  2 0 ) Number of digits for [0, P]: k =  log r (P + 1)  =  log r P  + 1 k–1 i=0

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 6 Unsigned Binary Integers Figure 9.1 Schematic “roulette wheel” representation of 4-bit code for integers in [0, 15]. Overflow marker Increasing values

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 7 Representation Range and Overflow Figure 9.2 Overflow regions in finite number representation systems. For unsigned representations covered in this section, max – = 0. Example 9.2, Part d Discuss if overflow will occur when computing 3 17 – 3 16 in a number system with k = 8 digits in radix r = 10. Solution The result is representable in the number system which has a range [0, ]; however, if 3 17 is computed en route to the final result, overflow will occur.

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Digit Sets and Encodings Conventional and unconventional digit sets  Decimal digits in [0, 9]; 4-bit BCD, 8-bit ASCII  Hexadecimal, or hex for short: digits 0-9 & a-f (or A-F)  Conventional ternary digit set in [0, 2] Conventional digit set for radix r is [0, r – 1] Symmetric ternary digit set in [–1, 1]  Conventional binary digit set in [0, 1] Redundant digit set [0, 2], encoded in 2 bits ( ) two and ( ) two both represent 22

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 9 Figure 9.3 Adding a binary number or another carry-save number to a carry-save number. The Notion of Carry-Save Addition Digit-set combination: {0, 1, 2} + {0, 1} = {0, 1, 2, 3} = {0, 2} + {0, 1}

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Number Radix Conversion  Perform arithmetic in the new radix R Suitable for conversion from radix r to radix 10 Horner’s rule: (x k–1 x k–2... x 1 x 0 ) r = (…((0 + x k–1 )r + x k–2 )r x 1 )r + x 0 ( ) two =  1   2   5   11   22   45   90   181  Perform arithmetic in the old radix r Suitable for conversion from radix 10 to radix R Divide the number by R, use the remainder as the LSD and the quotient to repeat the process 19 / 3  rem 1, quo 6 / 3  rem 0, quo 2 / 3  rem 2, quo 0 Thus, 19 = (2 0 1) three Two ways to convert numbers from an old radix r to a new radix R

October 2005Michael Frank, FAMU-FSU College of Engineering 11 Expression for Digits using Modulo Method

October 2005Michael Frank, FAMU-FSU College of Engineering 12 A Third Method  Also uses modulo arithmetic in the old radix r.  First, find k =  log R x , i.e., R k is greatest integer power of R that is ≤ x.  Digit #k (MSD) is then just the quotient  x/R k   Repeat the process using the remainder (x mod R k ) to find later digits in the sequence.

October 2005Michael Frank, FAMU-FSU College of Engineering 13 Digits with Third Method

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 14 Justifications for Radix Conversion Rules Figure 9.4 Justifying one step of the conversion of x to radix 2. Justifying Horner’s rule.

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Signed Integers  We dealt with representing the natural numbers  Signed or directed whole numbers = integers {...,  3,  2,  1, 0, 1, 2, 3,... }  Signed-magnitude representation +27 in 8-bit signed-magnitude binary code –27 in 8-bit signed-magnitude binary code –27 in 2-digit decimal code with BCD digits  Biased representation Represent the interval of numbers [  N, P] by the unsigned interval [0, P + N]; i.e., by adding N to every number

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 16 Two’s-Complement Representation Figure 9.5 Schematic roulette wheel representation of 4-bit 2’s- complement code for integers in [–8, +7]. With k bits, numbers in the range [–2 k–1, 2 k–1 – 1] represented. Negation is performed by inverting all bits and adding 1. Turn y notches clockwise to subtract y Overflow marker Increasing values

October 2005Michael Frank, FAMU-FSU College of Engineering 17 Another way to think about two’s complement representation  All we’re really doing is taking the block of all bit patterns that start with 1 and re-mapping it, shifting it over to cover the part of the number line located just to the left of 0. While leaving them in the same order relative to each other. Basically, we’re subtracting 2 n from the values of all these patterns. We’re re-valuing the high-order bit position from +2 n-1 to −2 n-1 ! −8 −7 … − … … … … 1111

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 18 Conversion from 2’s-Complement to Decimal Example 9.7 Convert x = ( ) 2’s-compl to decimal. Solution Given that x is negative, one could change its sign and evaluate –x. Shortcut: Use Horner’s rule, but take the MSB as negative –1   –2   –3   –5   –10   –19   –38   –75 Example 9.8 Sign Change for a 2’s-Complement Number Given y = ( ) 2’s-compl, find the representation of –y. Solution –y = ( ) + 1 = ( ) 2’s-compl (i.e., 75)

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 19 Two’s-Complement Addition and Subtraction Figure 9.6 Binary adder used as 2’s-complement adder/subtractor.

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Fixed-Point Numbers Positional representation: k whole and l fractional digits Value of a number: x = (x k–1 x k–2... x 1 x 0. x –1 x –2... x –l ) r =  x i r i For example: = (10.011) two = (1  2 1 ) + (0  2 0 ) + (0  2  1 ) + (1  2  2 ) + (1  2  3 ) Numbers in the range [0, r k – ulp] representable, where ulp = r –l Fixed-point arithmetic (addition & subtraction) same as integer arithmetic (radix point implied, not explicit) Two’s complement properties (including sign change) hold here as well: (01.011) 2’s-compl = (–0  2 1 ) + (1  2 0 ) + (0  2 –1 ) + (1  2 –2 ) + (1  2 –3 ) = (11.011) 2’s-compl = (–1  2 1 ) + (1  2 0 ) + (0  2 –1 ) + (1  2 –2 ) + (1  2 –3 ) = –0.625

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 21 Fixed-Point 2’s-Complement Numbers Figure 9.7 Schematic representation of 4-bit 2’s-complement encoding for (1 + 3)-bit fixed-point numbers in the range [–1, +7/8].

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 22 Radix Conversion for Fixed-Point Numbers  Perform arithmetic in the new radix R Evaluate a polynomial in r –1 : (.011) two = 0  2 –1 + 1  2 –2 + 1  2 –3 Simpler: View the fractional part as integer, convert, divide by r l (.011) two = (?) ten Multiply by 8 to make the number an integer: (011) two = (3) ten Thus, (.011) two = (3 / 8) ten = (.375) ten  Perform arithmetic in the old radix r Multiply the given fraction by R, use the whole part as the MSD and the fractional part to repeat the process (.72) ten = (?) two 0.72  2 = 1.44, so the answer begins with  2 = 0.88, so the answer begins with 0.10 Convert the whole and fractional parts separately. To convert the fractional part from an old radix r to a new radix R:

June 2005Computer Architecture, Instruction-Set ArchitectureSlide Floating-Point Numbers  Fixed-point representation must sacrifice precision for small values to represent large values x = ( ) two Small number y = ( ) two Large number  Neither y 2 nor y / x is representable in the format above  Floating-point representation is like scientific notation:  =  2  = 7  10 –9 Useful for applications where very large and very small numbers are needed simultaneously SignificandExponent Exponent base Also, 7E  9

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 24 ANSI/IEEE Standard Floating-Point Format (IEEE 754) Figure 9.8 The two ANSI/IEEE standard floating-point formats. Short exponent range is –127 to 128 but the two extreme values are reserved for special operands (similarly for the long format) Revision (IEEE 754R) is being considered by a committee

June 2005Computer Architecture, Instruction-Set ArchitectureSlide 25 Short and Long IEEE 754 Formats: Features Table 9.1 Some features of ANSI/IEEE standard floating-point formats FeatureSingle/ShortDouble/Long Word width in bits3264 Significand in bits hidden hidden Significand range[1, 2 – 2 –23 ][1, 2 – 2 –52 ] Exponent bits811 Exponent bias Zero (±0)e + bias = 0, f = 0 Denormal e + bias = 0, f ≠ 0 represents ±0.f  2 –126 e + bias = 0, f ≠ 0 represents ±0.f  2 –1022 Infinity (  ∞) e + bias = 255, f = 0e + bias = 2047, f = 0 Not-a-number (NaN)e + bias = 255, f ≠ 0e + bias = 2047, f ≠ 0 Ordinary number e + bias  [1, 254] e  [–126, 127] represents 1.f  2 e e + bias  [1, 2046] e  [–1022, 1023] represents 1.f  2 e min 2 –126  1.2  10 –38 2 –1022  2.2  10 –308 max   3.4    1.8 

October 2005Michael Frank, FAMU-FSU College of Engineering 26 Hand-Converting Numbers to Binary Floating-Point  Example: convert  10 6 to 32-bit floating point.  log 2 5,614,000 = … Take the floor  22  Base-2 exponent is 22, add bias (127)  149 Convert to 8-bit binary  1001,0101 for exponent field  Divide original number by 2 22 or 4,194,304 Gives us (significand)  Multiply fractional part by 2 23 or 8,388,608 Gives  Convert this to a 23-bit binary number  010,1011,0101,0011,0110,0000  Now just put the pieces together!

October 2005Michael Frank, FAMU-FSU College of Engineering 27 Conversion example, cont.  The fields are: Sign field (sgn) = 0 (positive) Exponent field (exp)= 1001,0101 ( = 149) Significand field (sig) = 010,1011,0101,0011,0110,0000  Thus, the full 32-bit binary word is: 0100,1010,1010,1011,0101,0011,0110,0000  Check answer: sgnexp sig