Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., 3.1416 –very small numbers, e.g.,.000000001 –very large.

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

Chapter Three.
Fabián E. Bustamante, Spring 2007 Floating point Today IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Datorteknik FloatingPoint bild 1 Floating point Number system corresponding to the decimal notation 1,837 * 10 significand exponent a great number of corresponding.
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.
University of Washington Today Topics: Floating Point Background: Fractional binary numbers IEEE floating point standard: Definition Example and properties.
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.
1  2004 Morgan Kaufmann Publishers Chapter Three.
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
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
CS/COE0447 Computer Organization & Assembly Language
FLOATING POINT COMPUTER ARCHITECTURE AND ORGANIZATION.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
Computer Arithmetic.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
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.
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,
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.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Computer Architecture Lecture 22 Fasih ur Rehman.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
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.
Floating Point Representations
Floating Point Borrowed from the Carnegie Mellon (Thanks, guys!)
Floating Point Numbers
2.4. Floating Point Numbers
CSCI206 - Computer Organization & Programming
Integer Division.
Lecture 9: Floating Point
Topics IEEE Floating Point Standard Rounding Floating Point Operations
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
CS/COE0447 Computer Organization & Assembly Language
CS 367 Floating Point Topics (Ch 2.4) IEEE Floating Point Standard
Topic 3d Representation of Real Numbers
ECE/CS 552: Floating Point
Number Representations
CSCI206 - Computer Organization & Programming
CS 105 “Tour of the Black Holes of Computing!”
How to represent real numbers
Computer Arithmetic Multiplication, Floating Point
Floating Point Arithmetic August 31, 2009
CS 105 “Tour of the Black Holes of Computing!”
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
CS213 Floating Point Topics IEEE Floating Point Standard Rounding
CS 105 “Tour of the Black Holes of Computing!”
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Computer Arithmetic Floating Point

We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers, e.g.,  10 9 Representation: –sign, exponent, significand: (–1) sign  significand  2 exponent –more bits for significand gives more accuracy –more bits for exponent increases range

Definitions A normalised number has no leading zeros –e.g is 1.0 x 10 -9

Binary Point e.g ten = two

IEEE 754 Floating Point Standard Single precision: 8 bits exponent, 23 bits significand –32 bits, C float –range: 2.0 x to 2.0 x Double precision: 11 bits exponent, 52 bits significand –64 bits: C double –range: 2.0 x to 2.0 x Ssignificandexponent S significand exponent

Pentium / PPC Internally, these architectures use an 80 bit floating point representation –defined by IEEE 754 as double-extended –15 exponent bits –64 significand bits CPU converts to double / float when reqd. 80-bit format poorly supported by programming languages

Sorting In an ideal world, the sort operation could use existing (integer) hardware. Board exercise: In what order do we check the fields of a floating point number when sorting? – x –0.234 x –0.187 x 10 1

IEEE 754 Floating Point Standard Exponent is “biased” to make sorting easier –all 0s is smallest exponent; all 1s is largest –bias of 127 for single precision and 1023 for double precision –summary: (–1) sign  significand)  2 exponent – bias Leading “1” bit of significand is implicit Board Exercise: encode in single precision

IEEE 754 Floating Point Standard Example: –decimal point: -.75 = -3/4 = -3/2 2 –binary point: x 2 0 = -1.1 x 2 -1 –floating point exponent = 126 = –IEEE single precision:

Floating Point Complexities Mathematical operations are somewhat more complicated 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 –positive divided by zero yields “infinity” –zero divided by zero yields “not a number” –other complexities Implementing the standard can be tricky Not using the standard can be even worse –see text for description of 80x86 and Pentium bug!

Floating Point Addition: Board Exercise x x Assume that we can only store –4 decimal digits of significand –2 decimal digits of exponent

e SignExponentSignificand Increment or decrement 0101 Shift smaller number right Compare exponents Add Normalize Round

Floating point Multiplication Multiply mantissas and add exponents Steps: –Add exponents –Multiply mantissas –Normalise result –Round results –Fix sign of product

Floating Point Accuracy Floating point numbers are normally approximations for the numbers they represent –infinite numbers between 0 and 1, but only 53 bits in double precision to represent them IEEE-754 keeps two extra bits on the right during intermediate calculations called guard and round respectively Example: add 2.56 ten * 10 0 to 2.34 ten *10 2 assuming three significant digits –with guard and round digits –without guard and round digits

Sticky Bit IEEE 754 allows for a third bit in addition to guard and round. in school we always rounded 0.5 up –error accumulates with each round –   0.8 –solution: use sticky bit, round down ~half the time –  0.7

Floating Point Accuracy Four Rounding modes : –round to nearest (default) –round towards plus infinity –round towards minus infinity –round towards 0

Examples GRSPlus infinityMinus infinityTruncateNearest even

Special Symbols Special symbols used by IEEE-754 –+  or -  (largest exponent with 0 mantissa) (result of divide by zero) –NaN (Not a number) (largest exponent with non 0 mantissa) (0/0 or  -  ) –Unnormalised Numbers (no explicit 1 in MSB) (0 exponent non-zero mantissa) –Zero (zero Mantissa and zero exponent)

Summary Single PrecisionDouble Precisionrepresents ExponentSignificandExponentSignificand Non-zero0 +/- denormalised number 1-254Anything1-2046Anything+/- floating point number /- infinity 255Non-zero2047Non-zeroNaN (not a number)