Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Similar documents
Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

Divide: Paper & Pencil

Floating Point Arithmetic

Number Systems. Both numbers are positive

Operations On Data CHAPTER 4. (Solutions to Odd-Numbered Problems) Review Questions

Exponential Numbers ID1050 Quantitative & Qualitative Reasoning

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Chapter 4. Operations on Data

Signed Multiplication Multiply the positives Negate result if signs of operand are different

Chapter 3: Arithmetic for Computers

FLOATING POINT NUMBERS

ECE232: Hardware Organization and Design

Module 2: Computer Arithmetic

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

CS321. Introduction to Numerical Methods

Chapter 4 Section 2 Operations on Decimals


Organisasi Sistem Komputer

Chapter 2 Data Representations

CHW 261: Logic Design

Data Representations & Arithmetic Operations

Introduction to Computers and Programming. Numeric Values

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

unused unused unused unused unused unused

COMP Overview of Tutorial #2

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

15213 Recitation 2: Floating Point

Foundations of Computer Systems

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

Data Representation Floating Point

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Numerical computing. How computers store real numbers and the problems that result

Section 1.4 Mathematics on the Computer: Floating Point Arithmetic

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Data Representation Floating Point

ECE331: Hardware Organization and Design

Computer Arithmetic Floating Point

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CO212 Lecture 10: Arithmetic & Logical Unit

Chapter Three. Arithmetic

LAB WORK NO. 2 THE INTERNAL DATA REPRESENTATION

Introduction to Computer Systems Recitation 2 May 29, Marjorie Carlson Aditya Gupta Shailin Desai

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Floating Point Arithmetic

On a 64-bit CPU. Size/Range vary by CPU model and Word size.

CHAPTER 5: Representing Numerical Data

1.2 Round-off Errors and Computer Arithmetic

Floating Point (with contributions from Dr. Bin Ren, William & Mary Computer Science)

Finite arithmetic and error analysis

IEEE Standard for Floating-Point Arithmetic: 754

CS 101: Computer Programming and Utilization

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

CHAPTER 1 Numerical Representation

Unit 3: Multiplication and Division Reference Guide pages x 7 = 392 factors: 56, 7 product 392

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

Programming Using C Homework 4

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Objectives. Connecting with Computer Science 2

Chapter 5 : Computer Arithmetic

Computer Organisation CS303

MACHINE LEVEL REPRESENTATION OF DATA

UNIT-III COMPUTER ARTHIMETIC

Floating Point Numbers

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

Floating Point Numbers

Floating Point Numbers

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

Digital Fundamentals

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

MIPS Integer ALU Requirements

Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Number Systems and Computer Arithmetic

Floating Point : Introduction to Computer Systems 4 th Lecture, May 25, Instructor: Brian Railing. Carnegie Mellon

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Calculations with Sig Figs

Lecture #15 March 3, 2004 A Worked Problem in Floating Point

Numeric Encodings Prof. James L. Frankel Harvard University

COMP2611: Computer Organization. Data Representation

Floating Point. EE 109 Unit 20. Floating Point Representation. Fixed Point

Number Systems CHAPTER Positional Number Systems

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating Point January 24, 2008

EE 109 Unit 19. IEEE 754 Floating Point Representation Floating Point Arithmetic

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

fractional quantities are typically represented in computers using floating point format this approach is very much similar to scientific notation

Floating Point Arithmetic

CMPSCI 145 MIDTERM #2 SPRING 2017 April 7, 2017 Professor William T. Verts NAME PROBLEM SCORE POINTS GRAND TOTAL 100

Internal Data Representation

Floating Point Arithmetic

EE 109 Unit 20. IEEE 754 Floating Point Representation Floating Point Arithmetic

Numeric Variable Storage Pattern

Fixed-Point Math and Other Optimizations

Transcription:

Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers

Objective To understand arithmetic operations in case of floating point numbers 2

Multiplication of Floating Point Numbers 3

Step 1 IEEE floating-point numbers use a biased representation exponents Add the exponent fields two floating-point numbers Treat exponent fields as integers for addition Subtract the bias value from the result 4

Step 2 Multiply the mantissas of the two numbers Using techniques analogous to those used to multiply decimal numbers, and to add their exponents 5

Step 3 Multiplied mantissas the result may need to be shifted so that only 1 bit remains to the left of the binary point (i.e., so that it fits the form 1.xxxxx 2, and the value of the sum of exponents incremented Shift such that the value of the mantissa 2 exponent remains the same 6

Step 4 The product of the mantissas after shifting may also have to be rounded to fit within the number of bits allocated to the fraction field, since the product of two n-bit mantissas may require up to 2 n bits to represent exactly Shifted and rounded mantissa Assemble final product out of the product of the mantissas and sum of exponents 7

Floating- Point Multiplication 8

Multiply 2.5 by 0.75 Using single-precision floating-point numbers 2.5 = 0b0100 0000 0010 0000 0000 0000 0000 0000 ( Exponent field of 0b10000000, Fraction field of 0b0100000 00000000 0000 0000 Mantissa of 1.010 0000 0000 0000 0000 0000 2 9

Multiply 2.5 by 0.75 Using single-precision floating-point numbers 0.75 = 0b0011 1111 0100 0000 0000 0000 0000 0000 Exponent field of 0b01111110 Fraction field of 0b100 0000 0000 0000 0000 0000 Mantissa of 1.100 0000 0000 0000 0000 0000 2 10

Multiply 2.5 by 0.75 Adding the exponent fields directly and subtracting the bias gives a result = 0b01111111 Multiplying the mantissas gives a result = 1.111 0000 0000 0000 0000 0000 2 Converts into a fraction field of 0b111 0000 0000 0000 0000 0000 Result is 0b0011 11111111 0000 0000 0000 0000 0000 = 1.111 2 2 0 = 1.875 11

Division of Floating Point Numbers 12

Floating-point division Very similar to multiplication the hardware computes the quotient of the mantissas and the difference between the exponents of the numbers being divided, adding the bias value to the difference between the exponent fields of the two numbers to get the correct biased representation of the result The quotient of the mantissas then shifted and rounded to fit within the fraction field of the result 13

Addition of Floating Point Numbers 14

Floating-point addition As with adding numbers in scientific notation, the first step is to shift one of the inputs until both inputs have the same exponent In adding floating-point numbers, the number with the smaller exponent is right-shifted 15

Next steps Once the inputs have been shifted, their mantissas are added, and the result shifted if necessary Finally, the result is rounded to fit in the fraction field, and the computation is complete 16

Adding 1.01 2 2 3 and 1.001 2 2 0 Smaller value is shifted to become 0.001001 2 2 3 Shifting the number with the smaller exponent allows the use of techniques that retain just enough information about the less-significant bits of the smaller number to perform rounding, reducing the number of bits that actually have to be added 17

Floating- Point Addition 18

Subtraction of Floating Point Numbers 19

Floating-point subtraction Uses the same process Except that the difference between, rather than the sum of the shifted mantissas is computed 20

Example of addition of Floating Point Numbers 21

Compute the sum of 0.25 and 1.5 using singleprecision floating-point numbers 0.25 = 0b0011 1110 1000 0000 0000 0000 0000 0000 (1.0 2 2 ) 1.5 = 0b0011 1111 1100 0000 0000 0000 0000 0000 (1.5 2 0) To add these numbers, shift the one with the smaller exponent (0.25) to the right until both exponents are the same (two places in this case) 22

Next steps This gives mantissas of 1.100 0000 0000 0000 0000 0000 and 0.010 000 0000 0000 0000 0000 for the two numbers (including the assumed 1s in the values to be shifted Adding these two mantissas gives a result of 1.110 0000 0000 0 0000 0000 2 0 (the exponent of the input with the larger exponent) = 1.75 The single-precision representation of the full result = 0b0011 1111 1110 0000 0000 0000 0000 0000 23

Result The single-precision representation of the full result = 0b0011 1111 1110 0000 0000 0000 0000 0000 24

Summary 25

We learnt Multiplication of floating point numbers Adding exponents and subtract bias Multiply mantissa Shift and round Division Addition by shifting lower number 26

End of Lesson 09 on Arithmetic using floating point numbers 27