Round-off Errors and Computer Arithmetic. The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus.

Slides:



Advertisements
Similar presentations
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Floating Point Numbers
1 IEEE Floating Point Revision Guide for Phase Test Week 5.
ECIV 201 Computational Methods for Civil Engineers Richard P. Ray, Ph.D., P.E. Error Analysis.
Round-Off and Truncation Errors
1 CSE1301 Computer Programming Lecture 30: Real Number Representation.
CSE1301 Computer Programming Lecture 33: Real Number Representation
Dr Damian Conway Room 132 Building 26
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
Number Systems Lecture 02.
Binary Representation and Computer Arithmetic
The Binary Number System
Data Representation Number Systems.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Simple Data Type Representation and conversion of numbers
Numerical Computations in Linear Algebra. Mathematically posed problems that are to be solved, or whose solution is to be confirmed on a digital computer.
Data Representation – Binary Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Information Representation (Level ISA3) Floating point numbers.
Computer Arithmetic Nizamettin AYDIN
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: October 22, 2004 Lecture Number: 24.
ECE232: Hardware Organization and Design
Data Representation.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
Round-off Errors.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
CSC 221 Computer Organization and Assembly Language
MECN 3500 Inter - Bayamon Lecture 3 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Numerical Analysis CC413 Propagation of Errors.
Copyright © Cengage Learning. All rights reserved. Fundamental Concepts of Algebra 1.1 Real Numbers.
Slide Copyright © 2009 Pearson Education, Inc. Unit 1 Number Theory MM-150 SURVEY OF MATHEMATICS – Jody Harris.
Errors in Numerical Methods
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Representation of Data (Part II) Computer Studies Notes: chapter 19 Ma King Man.
ESO 208A/ESO 218 LECTURE 2 JULY 31, ERRORS MODELING OUTPUTS QUANTIFICATION TRUE VALUE APPROXIMATE VALUE.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
Numerical Analysis CC413 Propagation of Errors. 2 In numerical methods, the calculations are not made with exact numbers. How do these inaccuracies propagate.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Module 2.2 Errors 03/08/2011. Sources of errors Data errors Modeling Implementation errors Absolute and relative errors Round off errors Overflow and.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Floating Point Representations
Machine arithmetic and associated errors Introduction to error analysis Class II.
Programming and Data Structure
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Number Representation
Floating Point Numbers: x 10-18
Chapter 6 Floating Point
Chapter 2 ERROR ANALYSIS
Recall our hypothetical computer Marc-32
CSCI206 - Computer Organization & Programming
Data Representation Data Types Complements Fixed Point Representation
(Part 3-Floating Point Arithmetic)
Approximations and Round-Off Errors Chapter 3
Computer Organization
Presentation transcript:

Round-off Errors and Computer Arithmetic

The arithmetic performed by a calculator or computer is different from the arithmetic in algebra and calculus courses. In our traditional mathematical world we permit numbers with an infinite number of digits. The arithmetic we use in this world defines as that unique positive number that when multiplied by itself produces the integer 3. In the computational world, however, each representable number has only a fixed and finite number of digits. This means, for example, that only rational numbers—and not even all of these—can be represented exactly. Since is not rational, it is given an approximate representation, one whose square will not be precisely 3, although it will likely be sufficiently close to 3.

Round-Off Error The error that is produced when a calculator or computer is used to perform real number calculations is called round-off error. It occurs because the arithmetic performed in a machine involves numbers with only a finite number of digits, with the result that calculations are performed with only approximate representations of the actual numbers. Error due to rounding should be expected whenever computations are performed using numbers that are not powers of 2. Keeping this error under control is extremely important when the number of calculations is large.

Binary Machine Numbers A 64-bit (binary digit) representation is used for a real number. The first bit is a sign indicator, denoted s. This is followed by an 11-bit exponent, c, called the characteristic, and a 52-bit binary fraction, f, called the mantissa. The base for the exponent is 2. Since 52 binary digits correspond to between 16 and 17 decimal digits, we can assume that a number represented in this system has at least 16 decimal digits of precision. the range of the exponent is actually from −1023 to 1024.

Normalization Representation for Floating-Point Number To save storage and provide a unique representation for each floating-point number, a normalization is imposed. Using this system gives a floating-point number of the form:

Example Consider the machine number The leftmost bit is s = 0, which indicates that the number is positive. The next 11 bits, , give the characteristic and are equivalent to the decimal number

Example (cont.) The exponential part of the number is, therefore, −1023 = 2 4. The final 52 bits specify that the mantissa is As a consequence, this machine number precisely represents the decimal number

Smallest and largest normalized positive number representation The smallest normalized positive number that can be represented has all 0’s except for the rightmost bit = 1: = = ( ) ≈ and the largest has leading 0 followed by all 1’s = = ( ) ≈

Underflow and Overflow Numbers occurring in calculations that have a magnitude less than ( ) result in underflow and are generally set to zero. Numbers greater than ( ) result in overflow.

Decimal Machine Numbers We will assume that machine numbers are represented in the normalized decimal floating- point form. for each i = 2,..., k. Numbers of this form are called k-digit decimal machine numbers.

Any positive real number within the numerical range of the machine can be normalized to the form The floating-point form of y, denoted f l(y), is obtained by terminating the mantissa of y at k decimal digits.

Chopping and Rounding There are two common ways of performing this termination. –One method, called chopping, is to simply chop off the digits dk+1dk This produces the floating- point form: –The other method, called rounding, adds to y and then chops the result to obtain a number of the form –For rounding, when dk+1 ≥ 5, we add 1 to dk to obtain f l(y); that is, we round up. When dk+1 < 5, we simply chop off all but the first k digits; so we round down.

Example Determine the five-digit (a) chopping and (b) rounding values of the irrational number π. Solution The number π has an infinite decimal expansion of the form π = Written in normalized decimal form, we have π = × 10. (a) The floating-point form of π using five-digit chopping is f l(π) = × 10 = (b) The sixth digit of the decimal expansion of π is a 9, so the floating-point form of π using five-digit rounding is f l(π) = ( ) × 10 =

Definition Suppose that p ∗ is an approximation to p. The absolute error is |p − p ∗ |, and the relative error is |p − p ∗ | / |p|, provided that p ≠ 0.

Example Determine the absolute and relative errors when approximating p by p ∗ when

Solution This example shows that the same relative error, ×10 −1, occurs for widely varying absolute errors. the absolute error can be misleading and the relative error more meaningful, because the relative error takes into consideration the size of the value.

Finite-Digit Arithmetic In addition to inaccurate representation of numbers, the arithmetic performed in a computer is not exact. Assume that the floating-point representations f l(x) and f l(y) are given for the real numbers x and y and that the symbols represent machine addition, subtraction, multiplication, and division operations, respectively. We will assume a finite-digit arithmetic given by

Example Suppose that x = 57 and y = 13. Use five-digit chopping for calculating x + y, x − y, x × y, and x ÷ y. Solution: Note that 

Solution (Cont.)