B0100 Floating Point ENGR xD52 Eric VanWyk Fall 2012.

Slides:



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

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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Floating Point Numbers
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.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
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.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
Numbers and number systems
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
B0010 Boolean Logic ENGR xD52 Eric VanWyk Fall 2012.
Computing Systems Basic arithmetic for computers.
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 10 Department of Computer Science and Software Engineering University of.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Integer and Fixed Point P & H: Chapter 3
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.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
CDA 3101 Fall 2013 Introduction to Computer Organization
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
B0001 Boolean Logic ENGR xD52 Eric VanWyk Fall 2013.
B0100 Floating Point ENGR xD52 Eric VanWyk Fall 2013.
b0000 Zero Day ENGR xD52 Eric VanWyk Fall 2014 Agenda General Awkwardness Basic Orientation Information Course Objectives & Details Eric’s guide to getting.
b0000 Zero Day ENGR xD52 Eric VanWyk Fall 2013 Agenda General Awkwardness Basic Orientation Information Course Objectives & Details VDub‘s guide to getting.
B0100 Floating Point ENGR xD52 Eric VanWyk Fall 2013.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Points & IEEE 754.
Floating Point Number system corresponding to the decimal notation
William Stallings Computer Organization and Architecture 7th Edition
Topic 3d Representation of Real Numbers
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Number Representations
Computer Science 210 Computer Organization
ECEG-3202 Computer Architecture and Organization
COMS 361 Computer Organization
Chapter 8 Computer Arithmetic
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
CS 286 Computer Architecture & Organization
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

b0100 Floating Point ENGR xD52 Eric VanWyk Fall 2012

Acknowledgements Mark L. Chang lecture notes for Computer Architecture (Olin ENGR3410) Patterson & Hennessy: Book & Lecture Notes Patterson’s 1997 course notes (U.C. Berkeley CS 152, 1997) Tom Fountain 2000 course notes (Stanford EE182) Michael Wahl 2000 lecture notes (U. of Siegen CS 3339) Ben Dugan 2001 lecture notes (UW-CSE 378) Professor Scott Hauck lecture notes (UW EE 471) Mark L. Chang lecture notes for Digital Logic (NWU B01)

Today Better IQ representation example Review Multiplication in Fixed Point Signed/Unsigned and Multiplication Invent Floating Point Numbers

Better IQ example

IQ Multiplication We ended last class with 3.0 *-0.5 in binary. 3-> I4Q > I4Q > I4Q4…?

Its just like Algebra, right? in I4Q4 * in I4Q ??? In I?Q?

Its just like Algebra, right? in I4Q4 * in I4Q In I8Q8

Its just like Algebra, right? in I4Q4 * in I4Q  I8Q8!! In I8Q8

Negative Second Operand? I2Q2 d1.75 * I2Q2 –d I4Q4 -d0.875

Negative Second Operand? I2Q2 d1.75 * I2Q2 –d  From sign extension!  No effect on output I4Q4 -d0.875

Observations The product is wider than the inputs – InQx*ImQy=I(n+m)Q(x+y) Sign extend the inner terms and the multiplicand

Side Note… The wikipedia article on binary multipliers is awful. Prove and rewrite the “More advanced approach: signed integers” section for Awesome.

Implications 3 categories of integer / IQ multiply instructions: – MULN*N->N, sign agnostic (only for Q=0) – SMULN*N->2N, signed – UMULN*N->2N, unsigned Multiplication uses ever increasing amounts of memory….?

Finite Memory We can’t expand every time. Usually, output format is input format. LSBs dropped are lost precision. MSBs dropped are occasional catastrophes. – Bonus Modulo!

Precision vs Max Magnitude Humans handle this with scientific notation *10^2 Significand * R^Exponent Significand in I?Q?, Exponent in I?

Renormalization We use 0<= Significand < R – 12.34*10^5 looks funny – it is in U2Q2(R10) – Scientific Notation is U1Q?R10. What is Engineering Notation? – *10^7 TLDR: Pick a significand format, stick with it

Renormalization We use 0<= Significand < R – 12.34*10^5 looks funny – it is in U2Q2(R10) – Scientific Notation is U1Q?R10. What is Engineering Notation? – *10^7 TLDR: Pick a significand format, stick with it

Exponent Format Could use 2’s compliment. Use ‘biased’ notation instead. – Signed value ‘biased’ to be unsigned. – Most negative number becomes 0. Makes sorting floats easy!

Multiplication in Floating Point Easy! Multiply Significands, Add Exponents 5*10^2 * 4*10^4 = (5*4)*10^(2+4) = 20*10^6 -> 2.0*10^7

Addition in Floating Point Almost Easy! Operands must have same exponent – Normalize to most positive exponent 9.8*10^13 + 4*10^12 -> ( )*10^13 = 10.2*10^13 -> 1.02*10^14

21 IEEE-754 Single Precision Float Floating Point (Float) = (-1) s * (1.significand) * 2 (exponent-127) Alternative Name: binary significandsexponent 1 bit 8 bits 23 bits

22 IEEE-754 Single Precision Float Floating Point (Float) = (-1) s * (1.significand) * 2 (exponent-127) Record Sign bit Convert Significand to U1Q23 – Track changes to Exponent! Drop the MSB of Significand, record the rest – Significand = leading one + Fraction Bias Exponent by +127, record significandsexponent

23 IEEE-754 Single Precision Board Work Floating Point (Float) = (-1) s * (1.significand) * 2 (exponent-127) Convert to fp hex: Convert from fp: 0x xC0FFEE significandsexponent

Special Cases Exponent b – Fraction = 0: Zero – Fraction!=0: Subnormal Exponent b – Fraction = 0: Infinity – Fraction!= 0: Not a Number

When things go wrong Overflow – it too big Underflow – it too small Non-Associative – Can’t reorder operations – Still commutative – Order determines end precision! Humans like R10, but it is not representable

Create your own Pain Create your own math problems that highlight these four basic problems with floating point math. You can use decimal for 3 of them – Pick a format. 2 exponent digits, 7 significand?

Storage vs Calculation Format Story Time!

If you remember nothing else… Precision: ~7 decimal digits Relative Error is constant, absolute error varies Exponent Range: 10^38 10^-38 Represent all integers up to 2^24 Zero is 0x Infinity is h7F800000, -Infinity is hFF NaN: h7F to h7FFFFFFF hFF to hFFFFFFFF h7FC00000 is most common I’ve seen. Sortable with integer operations

IEEE-754 Double Precision Float AKA Binary64 11 exponent bits, 52 explicit significand bits ~16 decimal digits, 10^308 10^-308 All Integers to 2^ significandsexponent significand (continued)

Homework Skim Chapter 3 of Hennessey Read in depth – 3.4 Division – 3.6 Parallelism and Associativity – 3.7 Real Stuff: Floating point in the x86 – 3.8 Fallacies and Pitfalls