1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)

Slides:



Advertisements
Similar presentations
Chapter 5 Data representation Data Rep.
Advertisements

Data Representation How integers are represented in computers?
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
A Simple ALU Binary Logic.
B261 Systems Architecture
Prof. Dr. Nizamettin AYDIN edu. tr
Number Systems  binary, octal, and hexadecimal numbers  why used  conversions, including to/from decimal  negative binary numbers  floating point.
Fixed-point and floating-point numbers CS370 Fall 2003.
Chapter 13 Numerical Issues
Lecture no 6. Two's Complement Given a negative number (N), represented using the Two's Complement representation (N*), the magnitude of the number (P)
Binary Number Systems.
4. Floating Point Numbers. Exponential Notation The representations differ in that the decimal place – the “point” -- “floats” to the left or right (with.
COMP3221 lec19-fp-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 19 : Floating Point Number Representation – I
Nat 4/5 Computing Science Lesson 1: Binary
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Datorteknik IntegerAddSub bild 1 Integer arithmetic Depends what you mean by "integer" Assume at 3-bit string. –Then we define zero = 000 one = 001 Use.
14-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 14: Gaming Engines, Coding Style, Floating Point.
1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar.
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
1 IEEE Floating Point Revision Guide for Phase Test Week 5.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
IT 251 Computer Organization and Architecture Introduction to Floating Point Numbers Chia-Chi Teng.
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.
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Computing Systems Basic arithmetic for computers.
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.
9.4 FLOATING-POINT REPRESENTATION
Floating-Point Representation We can store integers and characters easily in binary, but what about fractions? ¼ =.25 = 2.5 * *
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
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.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
CSE 340 Simulation Modeling | MUSHFIQUR ROUF CSE340:
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.
Chapter 9 Computer Arithmetic
Floating Point Representations
Floating Point Numbers: x 10-18
William Stallings Computer Organization and Architecture 7th Edition
Number Representations
Computer Arithmetic Multiplication, Floating Point
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Floating Point Numbers
Number Representations
Presentation transcript:

1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)

2 Outline Review of floating point scientific notation Floating point binary IEEE Floating Point Standard Addition in Floating Point Remarks about multiplication

3 Floating Point Notation Decimal ten (decimal notation) means 10* /10 + 5/ / /10000 In scientific notation = * = * = * = * = * = * * *10 1 is an example of normalised scientific notation.

4 Floating Point in Binary Binary two = (0/2) + (1/2 2 ) + (0/2 4 ) +(1/2 5 ) + (1/2 6 ) 0 + 1/ /32 + 1/64 = ( ) ten = ten In scientific notation 10011*2 -6 = *2 -5 = = *2 -4 = *2 -2 normalised

5 Normalised Notation In normalised binary scientific notation unless the number is 0 always have 1.sssssss...sss * 2 E sss...sss is the significand E is the exponent The significand s 1 s 2...s n represents

6 Representation Note that it is impossible to exactly represent all decimal numbers in this way (eg 0.3) Problem of representation of floating point numbers in fixed word length need to represent sign significand exponent in one word (32 bits).

7 Representation Represents floating point number: (-1) S * (1.0+F) * 2 E S is 1 bit (if S=1 then negative) F is 23 bits E is 8 bits sign bit S exponent 8 bits E significand: 23 bits F

8 Squeezing out More from the Bits Since every non-zero binary f.p. number (normalised) is of the form: 1.sss...sss *2 E We do not have to represent explicitly the 1 in the word, and can therefore interpret the bit- pattern as: (-1) S (1 + significand) * 2 E thus reclaiming an extra bit! E= is reserved for zero.

9 Requirements As far as possible the ALU should be able to reuse integer machinery in implementation of f.p. Eg, comparison with zero easy because of sign bit fp numbers can be easily classified as negative, zero or positive without additional hardware. Comparison of two fp numbers x<y not so straightforward - how are negative exponents to be formed?

10 Bad Example: (1/2) > 2 ??? Representation of 1/2 is 0.1 two = 1.0*2 -1 (normalised) S E significand l Representation of 2 is »10 two = 1.0*2 1 (normalised) S E significand

11 Representation of Exponent Inappropriate to use twos complement for the exponent Ideally want to represent most negative number, most positive. Number range: use this for 2 0 positive negative = 127 ten

12 Biased Representation (IEEE FP Standard) The bias 127 represents to 255 represent positive exponents 1 to 127 represent negative exponents (remember 0 is reserved for the entire number being zero). The actual exponent is therefore: E - bias (-1) S * (1 + significand) * 2 E-bias

13 Example 1 Represent ten = 5/16 5/16 = 1/4 + 1/16 = two = 1.01*2 -2 S = 0 E = ??? -2 = E-bias = E-127 E = 125 ten = two Significand = 010.…

14 Example 2 What does represent? S = 0 E = = 125 ten Exponent = E-bias = = -2 Significand = 1/4 (-1) S (1+sig.)2 E-bias = (1 + 1/4)*(1/4) = 5/16

15 Addition of FP Numbers Given two numbers: normalise them both adjust the floating point of the smaller number to match the larger one Add them together renormalise check for underflow/overflow of exponent if so then break; round significand to required number of bits might need renormalisation (eg, round to 4 bits).

16 Addition Example = two two 1.0* * * * *2 1 (already normalised) (1 + (1/2) + (1/8)) *

17 Remarks The IEEE FP standard represents floats in 32 bits, higher precision represented across two words (doubles). Multiplication is relatively easy, since the exponents add, and the significands can be done with integer multiplication. There can be huge pitfalls in reliably transferring floating point code to different hardware!

18 Summary FP scientific notation normalised representation in binary Bias to represent -ve to +ve range in exponent Addition Notice how a 32-bit binary string can represent many different entities in memory. Memory architectures NEXT.