10/7/2004Comp 120 Fall 20041 October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.

Slides:



Advertisements
Similar presentations
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
Advertisements

Chapter Three.
Computer Organization CS224 Fall 2012 Lesson 19. Floating-Point Example  What number is represented by the single-precision float …00 
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
L11 – Floating Point 1 Comp 411 – Fall /21/2009 Floating-Point Arithmetic Reading: Study Chapter 3.5 Skim if ((A + A) - A == A) { SelfDestruct()
1  2004 Morgan Kaufmann Publishers Chapter Three.
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
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:
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
February 26, 2003MIPS floating-point arithmetic1 Question  Which of the following are represented by the hexadecimal number 0x ? —the integer.
Computer Organization and Design Floating-Point Arithmetic
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Ellen Spertus MCS 111 October 11, 2001 Floating Point Arithmetic.
Computing Systems Basic arithmetic for computers.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /14/2013 Lecture 16: Floating Point Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
1 ECE369 Sections 3.5, 3.6 and ECE369 Number Systems Fixed Point: Binary point of a real number in a certain position –Can treat real numbers as.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
Computer Organization and Design More Arithmetic: Multiplication, Division & Floating-Point Montek Singh Mon, Nov 5, 2012 Lecture 13.
Lecture 9: Floating Point
Floating Point Representation for non-integral numbers – Including very small and very large numbers Like scientific notation – –2.34 × –
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
FLOATING POINT ARITHMETIC P&H Slides ECE 411 – Spring 2005.
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.
CHAPTER 3 Floating Point.
CDA 3101 Fall 2013 Introduction to Computer Organization
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
CSE 340 Simulation Modeling | MUSHFIQUR ROUF CSE340:
Numbers in Computers.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
Montek Singh Apr 8, 2016 Lecture 12
Computer Architecture & Operations I
Floating-Point Arithmetic
CS 232: Computer Architecture II
Floating-Point Arithmetic
CS/COE0447 Computer Organization & Assembly Language
Montek Singh Nov 8, 2017 Lecture 12
Topic 3d Representation of Real Numbers
Number Representations
How to represent real numbers
Computer Arithmetic Multiplication, Floating Point
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Chapter 3 Arithmetic for Computers
More Arithmetic: Multiplication, Division, and Floating-Point
Floating Point Numbers
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
Number Representations
Presentation transcript:

10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point

10/7/2004Comp 120 Fall What is the problem? Many numeric applications require numbers over a VERY large range. (e.g. nanoseconds to centuries) Most scientific applications require fractions (e.g.  ) But so far we only have integers. We *COULD* implement the fractions explicitly (e.g. ½, 1023/102934) We *COULD* use bigger integers Floating point is a better answer for most applications.

10/7/2004Comp 120 Fall Just Scientific Notation for computers (e.g    Representation in IEEE 754 floating point standard –value = (1-2*sign)  significand  2 exponent –more bits for significand gives more precision –more bits for exponent increases range Floating Point sign 1exponent 8significand or mantissa 23 sign 1exponent 11significand or mantissa 52 single double 32 bits 64 bits Remember, these are JUST BITS. It is up to the instruction to interpret them.

10/7/2004Comp 120 Fall Normalization In Scientific Notation: = 1234 x 10 3 = x 10 6 Likewise in Floating Point = 1011 x 2 3 = x 2 6 The standard says we should always keep them normalized so that the first digit is 1 and the binary point comes immediately after. But wait! There’s more! If we know the first bit is 1 why keep it? Normalized

10/7/2004Comp 120 Fall IEEE 754 floating-point standard Leading “1” bit of significand is implicit We want both positive and negative exponents for big and small numbers. Exponent is “biased” to make comparison easier –all 0s is smallest exponent all 1s is largest –bias of 127 for single precision and 1023 for double precision –summary: (1-2*sign)  significand)  2 exponent – bias Example: –decimal: -.75 = -3/4 = -3/2 2 –binary: -.11 = -1.1 x 2 -1 –floating point: exponent = 126 = –IEEE single precision: What about zero?

10/7/2004Comp 120 Fall Arithmetic in Floating Point In Scientific Notation we learned that to add to numbers you must first get a common exponent: 1.23 x 10^ x 10^6 == x 10^ x 10^6 == x 10^6 In Scientific Notation, we can multiply numbers by multiplying the significands and adding the exponents –1.23 x 10^3 x 4.56 x 10^6 == –(1.23 x 4.56) x 10^(3+6) == –5.609 x 10^9 We use exactly these same rules in Floating point PLUS we add a step at the end to keep the result normalized.

10/7/2004Comp 120 Fall Floating point AIN’T NATURAL It is CRUCIAL for computer scientists to know that Floating Point arithmetic is NOT the arithmetic you learned since childhood 1.0 is NOT EQUAL to 10*0.1 (Why?)  1.0 * 10.0 == 10.0  0.1 * 10.0 != 1.0  0.1 decimal == 1/16 + 1/32 + 1/ / / … == …  In decimal 1/3 is a repeating fraction …  If you quit at some fixed number of digits, then 3 * 1/3 != 1 Floating Point arithmetic IS NOT associative x + (y + z) is not necessarily equal to (x + y) + z Addition may not even result in a change (x + 1) MAY == x

10/7/2004Comp 120 Fall Floating Point Complexities In addition to overflow we can have “underflow” Accuracy can be a big problem –IEEE 754 keeps two extra bits, guard and round –four rounding modes Non-zero divided by zero yields “infinity” INF Zero divided by zero yields “not a number” NAN Implementing the standard can be tricky Not using the standard can be worse

10/7/2004Comp 120 Fall MIPS Floating Point Floating point “Co-processor” 32 Floating point registers –separate from 32 general purpose registers –32 bits wide each. –use an even-odd pair for double precision add.d fd, fs, ft # fd = fs + ft in double precision add.s fd, fs, ft# fd = fs + ft in single precision sub.d, sub.s, mul.d, mul.s, div.d, div.s, abs.d, abs.s l.d fd, address# load a double from address l.s, s.d, s.s Conversion instructions Compare instructions Branch (bc1t, bc1f)

10/7/2004Comp 120 Fall Chapter Four Summary Computer arithmetic is constrained by limited precision Bit patterns have no inherent meaning but standards do exist –two’s complement –IEEE 754 floating point Computer instructions determine “meaning” of the bit patterns Performance and accuracy are important so there are many complexities in real machines (i.e., algorithms and implementation). Accurate numerical computing requires methods quite different from those of the math you learned in grade school.