Floating Point Numbers 3-3-2003. Opening Discussion zWhat did we talk about last class? zHave you seen anything interesting in the news?

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 
CSCE 212 Chapter 3: Arithmetic for Computers Instructor: Jason D. Bakos.
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.
Floating Point Numbers
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.
Floating Point Numbers. CMPE12cCyrus Bazeghi 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or 2 64.
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:
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
CPSC 321 Computer Architecture ALU Design – Integer Addition, Multiplication & Division Copyright 2002 David H. Albonesi and the University of Rochester.
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of 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
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
IT253: Computer Organization
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.
Data Representation in Computer Systems
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 5 Unsigned integer and floating point.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /14/2013 Lecture 16: Floating Point Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
9.4 FLOATING-POINT REPRESENTATION
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Floating Point Representation for non-integral numbers – Including very small and very large numbers Like scientific notation – –2.34 × –
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
CHAPTER 3 Floating Point.
CDA 3101 Fall 2013 Introduction to Computer Organization
CSE 340 Simulation Modeling | MUSHFIQUR ROUF CSE340:
Numbers in Computers.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
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.
Computer Organization & Design 计算机组成与设计 Weidong Wang ( 王维东 ) College of Information Science & Electronic Engineering 信息与通信工程研究所 Zhejiang.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Floating Point Representations
Fundamentals of Computer Science
Morgan Kaufmann Publishers Arithmetic for Computers
Dr. Clincy Professor of CS
Computer Architecture & Operations I
Lecture 9: Floating Point
CS/COE0447 Computer Organization & Assembly Language
Computer Organization & Design 计算机组成与设计
Arithmetic for Computers
CSCE 350 Computer Architecture
Number Representations
How to represent real numbers
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
Digital System Design II 数字系统设计2
Chapter 3 Arithmetic for Computers
Number Representations
Presentation transcript:

Floating Point Numbers

Opening Discussion zWhat did we talk about last class? zHave you seen anything interesting in the news?

Fractions in Binary zOnce again, we can explain concepts in binary by looking at their equivalent in decimal. In this case, all the numbers to the right of the point are multiplied by negative powers of the base we are using. zNote that not all numbers can be equally well represented in different bases. For example, 0.1 ten requires an infinite repeating series in base two.

Scientific Notation zWe could do a “fixed point” notation by arbitrarily placing a point after one of the bits in our 32 bit numbers. However, we can do better than that by borrowing from scientific notation. zIn this format the point “floats” because we always multiply by some power of our base. In normalized form, we make it so there is only a 1 left of the point.

Floating Point Format zA word can be broken up in any number of ways to store a floating point number. The standard division between precision and size range is to have 8 bits for the exponent and 23 for the mantissa. One other bit is used for the sign. zDouble precision numbers use 64 bits. They still have one sign bit, but use 11 bits for the exponent and 52 for the mantissa. They have very good precision.

Gaining a Bit zThe highest bit of the mantissa is implicitly on so it is not stored. zThis causes a problem for zero which shouldn’t have a leading 1. An exponent of zero implies that the number has a value of zero. This has problems for numbers between 1 and 2 and your book doesn’t explain that sufficiently.

Exponents and Sorting zThe developers of the IEEE 754 standard wanted to enable fast comparison with integer compares. That is part of the reason the sign bit is first. zFor this reason the exponent is stored with biased notation instead of two’s complement. For single precision numbers, the real exponent is the binary value, minus 127. zInteger compares give the right result.

Addition of Floating Point Numbers zFirst, align the points by shifting the number with the smaller exponent. zSecond, add the mantissas. zThird, check if it is normalized and if not, normalize it and check for overflow or underflow of the exponent. zFourth, round the result to the proper number of bits. zUnfortunately this is quite serial.

Multiplication of Floating Point Numbers zFirst, add the exponents (we have to subtract out the bias because it is in the sum twice). zSecond, multiply the mantissas. zThird, normalize the results if they aren’t normalized and check for overflow or underflow. zFourth, round the result and determine the sign. zNote that 1 and 2 can be done in parallel.

Subtraction and Division zSubtraction is done simply with addition after the sign bit has been changed. zFor division, it turns out to be faster to take the multiplicative inverse, then do multiplication so there isn’t a separate division algorithm either (other than that required for finding the inverse.

Floating Point in MIPS zMIPS has a set of instructions for dealing with floating point values. yadd.s and add.d for single and double adds. ysub.s and sub.d ymul.s and mul.d ydiv.s and div.d ycomparisons are done with c.x.s and c.x.d where x can be eq, neq, lt, le, gt, or ge ybranch with bclt and bclf, for branching on true and false.

More about MIPS zThere are separate floating point registers in MIPS, $f0, $f1, $f2, …, $f31 They use different load an store commands: lwc1 and swc1. Double precision numbers are stored in consecutive registers starting with an even numbered one. zNote that we don’t have as many specialized registers. Nor are there immediate forms. The constants have to be put into global memory.

Minute Essay zWrite the number in single precision floating point format. Remember, there is one bit for the sign, 8 for the exponent, and 31 for the mantissa, but the highest bit is just assumed to be on.