CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic.

Slides:



Advertisements
Similar presentations
Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
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.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.
COMP3221: Microprocessors and Embedded Systems Lecture 14: Floating Point Numbers Lecturer: Hui Wu Session 2, 2004.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
Number Systems Standard positional representation of numbers:
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
CS 61C L10 Floating Point (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #10: Floating Point
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
FLOATING POINT COMPUTER ARCHITECTURE AND ORGANIZATION.
Introduction to Computing Systems from bits & gates to C & beyond Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
Numbers and number systems
IT 251 Computer Organization and Architecture Introduction to Floating Point Numbers Chia-Chi Teng.
Ch. 2 Floating Point Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Arithmetic Nizamettin AYDIN
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Number Systems So far we have studied the following integer number systems in computer Unsigned numbers Sign/magnitude numbers Two’s complement numbers.
Computing Systems Basic arithmetic for computers.
ECE232: Hardware Organization and Design
Floating Point Numbers Topics –IEEE Floating Point Standard –Rounding –Floating Point Operations –Mathematical properties.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
9.4 FLOATING-POINT REPRESENTATION
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CS 61C L3.2.1 Floating Point 1 (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Floating Point Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Computer Architecture Lecture 22 Fasih ur Rehman.
CDA 3101 Fall 2013 Introduction to Computer Organization
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
CSE 340 Simulation Modeling | MUSHFIQUR ROUF CSE340:
Numbers in Computers.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
1 Floating Point. 2 Topics Fractional Binary Numbers IEEE 754 Standard Rounding Mode FP Operations Floating Point in C Suggested Reading: 2.4.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Floating Point Representations
2.4. Floating Point Numbers
CSCI206 - Computer Organization & Programming
Lecture 9: Floating Point
Topics IEEE Floating Point Standard Rounding Floating Point Operations
CS 232: Computer Architecture II
IEEE floating point format
April 2006 Saeid Nooshabadi
Arithmetic for Computers
Topic 3d Representation of Real Numbers
ECE/CS 552: Floating Point
Chapter 2 Bits, Data Types & Operations Integer Representation
Number Representations
CS 61C: Great Ideas in Computer Architecture Floating Point Arithmetic
How to represent real numbers
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Floating Point Numbers
Topic 3d Representation of Real Numbers
CS 286 Computer Architecture & Organization
Number Representations
Presentation transcript:

CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic

Integers Using an 8-bit pattern, how many different integers can we represent? 2 8 Correct? How can we represent negative integers? Use a sign bit How many different integers are there?

Small Numbers How can we represent numbers that are smaller than 1?

Fixed Point Data Type  Bit pattern:  Binary point just to the right of sign bit (in text)  Can be anywhere inside bit pattern  Binary point to far right of bit pattern  What do we get?  Integer  Value of bit pattern as integer:  Value of bit patt. as fixed point:

Blocked Floating Point Fixed point → Low cost floating point Exponent kept in separate variable Exponent shared by a set of fixed point variables Applications? Overflow?

Saturating Arithmetic In DSP, if result is too large to be represented, it is set to the largest representable number with the appropriate sign What happens when we get a floating-point overflow?

IEEE 754 Floating-Point (32 bit) Value=(–1) s (1+f) 2 (e–127) Significand =1+f Compare: scientific notation, say 3.45 × 10 6 Base=2 So, 13 is represented by1.101 × 2 3 withs=0, e= , f=10100…00 Can you give one advantage of the implicit 1? Can you give one disadvantage of the implicit 1? … … se: exponentf: fraction 1 bit 8 bits 23 bits

IEEE 754 Floating-Point (64 bit) 1 bit 11 bits 52 bits Value=(–1) s (1+f) 2 (e–1023) Significand =1+f … … se : exponentf : fraction

Base IEEE:2 Other bases:16IBM 8Burroughs Normalize such that the first digit is nonzero For base 16, the first digit could be 1, 2, …, 14, 15 Need new symbols to represent 10,11, 12, 13, 14, 15 What is base 16 called?

Hexadecimal What is hexa? Greek for six What is decimal? Latin for ten What is Latin prefix for six? Sexa What is old name for base 16? Sexidecimal Which company changed the name?

Hexadecimal System For base 16, we have 1 = 1/16 × 16 1 withf = …00, 2= 2/16 × 16 1 withf = …00, 4 = 4/16 × 16 1 withf = …00, 8 = 8/16 × 16 1 withf = …00, 16= 1/16 × 16 2 withf = …00, Disadvantage:As many as three leading zero bits Advantage:Base larger → Range larger 32 bit FP rep.:1 sign bit, 7 exp. bits, 24 fraction bits (exponent bias = 64).

Floating Point Representation of 1 IEEE: s = 0, e = , f = 00000…00; Value=(1) 2 (127–127) = 1. IBM Hexadecimal: s = 0, e = , f = …00; Value=(1/16) 16 (65–64) = 1.

IEEE FP Representation of One to Sixteen Numbersef

Integer Comparisons of FP Number Ease to use Sorting Sign bit is most significant:  Easy to check if number is greater than, less than, or equal to zero Exponent before fraction:  Larger exponent → larger number  Use bias such that exponent values ≥ 0  1 ≤ e ≤ 254 → –126 ≤ e – bias ≤ 127  e = 0 and e = 255?

Representation of Zero All bits (except sign bit) equal zero e = 0 → zero exponent field Zero fraction field (no implicit 1) Plus and minus zero

Denormal Numbers e = 0 → zero exponent field f ≠ 0 → no implicit 1 Value = (–1) s *f *2 –126 Gradual underflow

IEEE Representation Fill in the blanks Numbersef –1 2 –2 2 –125 2 –126 2 –127 2 –128 2 –129 2 –149

Underflow to Zero In old days, a FP number that underflowed could be set to zero An old “fast” test for equality: If a − b = 0, then a = b Test would fail if a − b underflowed

Infinity e = 11…1 → maximum exponent field Zero fraction field Plus and minus infinity 1/0 = ∞; 1+∞ = ∞ Useful in trigonometry: sin(tan –1 ∞) = sin π/2 = 1

NaN Not a Number e = 11…1 → maximum exponent field Nonzero fraction field Can you give an operation that generates NaN? What is 1+NaN?

Examples Largest positive number: s = 0, e = , f = 11111…11; Value=(1+2 –1 +…+2 –23 ) 2 (254–127) =(2−2 –23 ) ≈ ≈ 2.56×10 38 One: s = 0, e = , f = 00000…00; Value=(1) 2 (127–127) = 1. Smallest positive normal number: s = 0, e = , f = 00000…00; Value=(1) 2 (1–127) =2 –126 ≈ 1.6×10 –38

Examples (2) Largest positive denormal number: s = 0, e = , f = 11111…11; Value=(2 –1 +…+2 –23 ) 2 –126 =(1−2 –23 ) 2 –126 ≈ 2 –126 Differs from smallest normal by 2 –149 Smallest positive denormal number: s = 0, e = , f = 00000…01; Value=(2 –23 ) 2 –126 = 2 –149 ≈ 2×10 –45 Plus zero: s = 0, e = , f = 00000…00.