CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

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 Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Floating Point Numbers

ECE232: Hardware Organization and Design

Floating Point Arithmetic

Numeric Encodings Prof. James L. Frankel Harvard University

COMP2611: Computer Organization. Data Representation

Floating Point Arithmetic

ECE331: Hardware Organization and Design

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

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

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Data Representation Floating Point

Computer Architecture Review. Jo, Heeseung

15213 Recitation 2: Floating Point

Data Representation Floating Point

Written Homework 3. Floating-Point Example (1/2)

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

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

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

Data Representation Floating Point

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

Floating Point Numbers

Floating Point Numbers

IEEE Standard for Floating-Point Arithmetic: 754

FLOATING POINT NUMBERS

Representing and Manipulating Floating Points. Jo, Heeseung

Finite arithmetic and error analysis

Computer Organization: A Programmer's Perspective

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

CS 33. Data Representation (Part 3) CS33 Intro to Computer Systems VIII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Computer Systems C S Cynthia Lee

System Programming CISC 360. Floating Point September 16, 2008

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

IEEE Floating Point Numbers Overview

Floating-point representations

Floating-point representations

Chapter Three. Arithmetic

Floating Point January 24, 2008

Thomas Polzer Institut für Technische Informatik

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

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

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

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

Representing and Manipulating Floating Points

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

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating-point representation

IEEE Standard 754 Floating Point Numbers

What we need to know about error: Class Outline. Computational Methods CMSC/AMSC/MAPL 460. Errors in data and computation

Representing and Manipulating Floating Points

CS429: Computer Organization and Architecture

Integers and Floating Point

Giving credit where credit is due

Inf2C - Computer Systems Lecture 2 Data Representation

Computational Methods CMSC/AMSC/MAPL 460. Representing numbers in floating point and associated issues. Ramani Duraiswami, Dept. of Computer Science

Giving credit where credit is due

Representing and Manipulating Floating Points

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon

Floating Point Numbers

Representing and Manipulating Floating Points. Computer Systems Laboratory Sungkyunkwan University

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

Chapter 3. Arithmetic Text: P&H rev

C NUMERIC FORMATS. Overview. IEEE Single-Precision Floating-point Data Format. Figure C-0. Table C-0. Listing C-0.

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

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

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

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

3.5 Floating Point: Overview

Foundations of Computer Systems

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

The Sign consists of a single bit. If this bit is '1', then the number is negative. If this bit is '0', then the number is positive.

2 Computation with Floating-Point Numbers

INTEGER REPRESENTATIONS

Divide: Paper & Pencil

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Up next. Midterm. Today s lecture. To follow

Number Systems. Both numbers are positive

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Floating Point Arithmetic

CO212 Lecture 10: Arithmetic & Logical Unit

Description Hex M E V smallest value > largest denormalized negative infinity number with hex representation 3BB0 ---

IEEE-754 floating-point

2 Computation with Floating-Point Numbers

Floating Point Numbers. Lecture 9 CAP

Computational Methods CMSC/AMSC/MAPL 460. Representing numbers in floating point and associated issues. Ramani Duraiswami, Dept. of Computer Science

1.2 Round-off Errors and Computer Arithmetic

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

Chapter 3: Arithmetic for Computers

MATH 353 Engineering mathematics III

CS 61C: Great Ideas in Computer Architecture Performance and Floating Point Arithmetic

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI.

CS101 Introduction to computing Floating Point Numbers

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

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

CS Computer Architecture. 1. Explain Carry Look Ahead adders in detail

Transcription:

CSCI 402: Computer Architectures Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI 3.5 Today s Contents Floating point numbers: 2.5, 10.1, 100.2, etc.. How can computers support these real numbers? 4 1

Concept of Floating Point Numbers Used to represent Real Numbers (non-integers) Also used to represent very small and very large numbers Scientific notation: A number has 1 single digit to the left of the decimal point Normalized: A number in scientific notation and it has no leading 0s. Some examples? normalized 2.34 10 56 +0.002 10 4 +987.02 10 9 not normalized Apply the same notation to binary numbers: ±1.xxxxxxx 2 2 yyyy Types float and double in C (or mantissa) significand Always the same format. Can simplify floating point arithmetic algorithms 5 IEEE Floating Point Standard There is a compromise between fraction and exponent bits for precision V bits for range However, we only have 32 or 64 bits More precision is always possible, but up to a cost Defined by IEEE Standard 754-1985 Developed in response to divergence of representations Resolve portability issues for scientific code Now, it is universally adopted. Two representations: Single precision floating point (32-bit) Double precision floating point (64-bit) 6 2

IEEE Floating-Point Format single: 8 bits double: 11 bits single: 23 bits double: 52 bits x = ( 1) S (1+) 2 [0, 255] (stored Exponent Bias) S: sign bit (0 Þ non-negative, 1 Þ negative) Normalized significand: 1.0 significand < 2.0 Always has a leading (pre-binary-point) 1, so no need to represent it explicitly ( hidden bit ) Significand = with the 1. restored Stored exponent = actual exponent + Bias Actual exponent = stored exponent - Bias Stored exponent is unsigned: e.g., 0 to 255, or 0 to 2047 Single: Bias = 127; Double: Bias = 1023 7 Single-Precision Range First of all: infinity Exponent of 0000 0000 and 1111 1111 are reserved The smallest value (closest to zero)? Exponent: 0000 0001 Þ actual exponent = 1 127 = 126 : 000 00 Þ significand = 1.0 ±1.0 2 126 ±1.2 10 38 The largest value (furthest from zero)? exponent: 1111 1110 Þ actual exponent = 254 127 = +127 : 111 11 Þ significand 2.0 ±2.0 2 +127 ±3.4 10 +38 8 3

Double-Precision Range Again, exponents 0000 00 and 1111 11 are reserved Smallest value Exponent: 000 0000 0001 Þ actual exponent = 1 1023 = 1022 : 000 00 Þ significand = 1.0 ±1.0 2 1022 ±2.2 10 308 Largest value Exponent: 111 1111 1110 Þ actual exponent = 2046 1023 = +1023 : 111 11 Þ significand 2.0 ±2.0 2 +1023 ±1.8 10 +308 Main advantage: much larger-size fraction! 9 Overflow and Underflow When a number becomes too big to be represented by the exponent field à Overflow i.e., > 2.0 2 +127 (float) When a number becomes too small to be represented in the exponent field à Underflow between ±1.0 2 126 (float) 10 4

IEEE 754 Encoding of Floating Point Numbers 0 is a special case in the IEEE 754 Std. It seems we have no way to represent 1.0, which would be 1.0x2 0 (an exponent of zero, times the hidden one)! 11 Denormalized Numbers Exponent = 000...0 Þ hidden bit is 0, i.e. S -Bias x = (-1) (0+ ) 2 n Smaller than normalized 1.xxxx numbers n Allow for gradual underflow n Denormalized number with fraction = 000...0 x = (-1) S (0+ 0) 2 Two representations of 0.0! -Bias = ±0.0 12 5

Representation of Infinities and NaNs Exponent = 111...1, = 000...0 ±Infinity e.g., 1/0 Can be used in subsequent calculations, avoiding the need for overflow check Exponent = 111...1, 000...0 Not-a-Number (NaN) Indicates illegal or undefined result e.g., 0.0 / 0.0, Inf - Inf Can still be used in subsequent calculations 13 Floating-Point# s Precision Precision: Minimum difference between two floating point numbers? For single (23-bit fraction): approximately 2 23 Equivalent to 23 log 10 2 23 0.3 6 decimal digits of precision Not sufficient for scientific computing! For double (52-bit fraction): approximately 2 52 Equivalent to 52 log 10 2 52 0.3 16 decimal digits of precision also called machine epsilon Minimum epsilon s.t. 1 + epsilon > 1. 14 6

Accuracy vs Precision Accuracy is how close a measured value is to the true value. Precision is how close the measured values are to each other. Low accuracy High precision High accuracy Low precision High accuracy High precision 15 7