FLOATING POINT NUMBERS

Similar documents
Floating Point Numbers

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

COMP Overview of Tutorial #2

ECE232: Hardware Organization and Design

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

COMP2611: Computer Organization. Data Representation

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

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

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

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

Floating-point representations

Floating-point representations

Floating Point Numbers

Floating Point Numbers

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

15213 Recitation 2: Floating Point

CHAPTER 5: Representing Numerical Data

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

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

Data Representation Floating Point

CO212 Lecture 10: Arithmetic & Logical Unit

Divide: Paper & Pencil

Floating Point Arithmetic

Data Representation Floating Point

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

Floating Point Representation in Computers

Floating Point Representation. CS Summer 2008 Jonathan Kaldor

Fixed Point. Basic idea: Choose a xed place in the binary number where the radix point is located. For the example above, the number is

Chapter 3: Arithmetic for Computers

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

Computer Arithmetic Floating Point

Chapter 4. Operations on Data

A Level Computing. Contents. For the Exam:

Integers and Floating Point

Introduction to Computers and Programming. Numeric Values

Inf2C - Computer Systems Lecture 2 Data Representation

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

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

Systems Programming and Computer Architecture ( )

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8

Floating Point January 24, 2008

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

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

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

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

Chapter 2 Data Representations

3.5 Floating Point: Overview

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

Data Representations & Arithmetic Operations

Floating Point Arithmetic

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

Finite arithmetic and error analysis


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

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.

Representing and Manipulating Floating Points. Jo, Heeseung

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

Floating Point Arithmetic

Representing and Manipulating Floating Points

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

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

Module 12 Floating-Point Considerations

System Programming CISC 360. Floating Point September 16, 2008

Numeric Encodings Prof. James L. Frankel Harvard University

Foundations of Computer Systems

Representing and Manipulating Floating Points

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

Module 2: Computer Arithmetic

Floating Point Arithmetic

Organisasi Sistem Komputer

Data Representation Floating Point

Giving credit where credit is due

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

Giving credit where credit is due

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

Introduction to Computer Science-103. Midterm

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Representing and Manipulating Floating Points

Representing and Manipulating Floating Points. Computer Systems Laboratory Sungkyunkwan University

1.2 Round-off Errors and Computer Arithmetic

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

CS429: Computer Organization and Architecture

CS 101: Computer Programming and Utilization

Number Systems. Both numbers are positive

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

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

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

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

MIPS Integer ALU Requirements

Exponential Numbers ID1050 Quantitative & Qualitative Reasoning

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Module 12 Floating-Point Considerations

Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point Numbers. Lecture 9 CAP

Computer Organization: A Programmer's Perspective

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

Transcription:

Exponential Notation FLOATING POINT NUMBERS Englander Ch. 5 The following are equivalent representations of 1,234 123,400.0 x 10-2 12,340.0 x 10-1 1,234.0 x 10 0 123.4 x 10 1 12.34 x 10 2 1.234 x 10 3 0.1234 x 10 4 The representations differ in that the decimal place the point -- floats to the left or right (with the appropriate adjustment in the exponent). Parts of a Floating Point Number Exponent Excess 50 Representation -0.9876 x 10-3 Exponent With 2 digits for the exponent and 5 for the mantissa: from.00001 x 10-50 to.99999 x 10 49 Sign of mantissa Location of decimal point Mantissa Sign of exponent Base

Overflows / Underflows Typical Floating Point Format From.00001 x 10-50 to.99999 x 10 49 1 x 10-55 to.99999 x 10 49 IEEE 754 Standard Single Precision Format Most common standard for representing floating point numbers Single precision: 32 bits, consisting of... Sign bit (1 bit) Exponent (8 bits) Mantissa (23 bits) Double precision: 64 bits, consisting of Sign bit (1 bit) Exponent (11 bits) Mantissa (52 bits) 32 bits Mantissa (23 bits) Exponent (8 bits) Sign of mantissa (1 bit)

Double Precision Format Normalization 64 bits Mantissa (52 bits) Exponent (11 bits) Sign of mantissa (1 bit) The mantissa is normalized Has an implied decimal place on left Has an implied 1 on left of the decimal place E.g., Mantissa: Representation: 10100000000000000000000 1.101 2 = 1.625 10 Excess Notation To include both positive and negative exponents, excess-n notation is used Single precision: excess 127 Double precision: excess 1023 The value of the exponent stored is n larger than the actual exponent E.g., excess 127, 10000111 Exponent: 135 127 = 8 (value) Representation: Excess Notation - Sample - Represent exponent of 14 10 in excess 127 form: 127 10 = + 01111111 2 14 10 = + 00001110 2 Representation = 10001101 2

Excess Notation - Sample - Represent exponent of -8 10 in excess 127 form: Single precision Example 0 10000010 11000000000000000000000 127 10 = + 01111111 2-8 10 = - 00001000 2 Representation = 01110111 2 1.11 2 = 1.75 10 130 127 = 3 0 = positive mantissa +1.75 2 3 = 14.0 Exercise Floating Point Conversion (1) What decimal value is represented by the following 32-bit floating point number? : Exercise Floating Point Conversion (1) What decimal value is represented by the following 32-bit floating point number? : -15.6875 Skip answer

Step by Step Solution Step by Step Solution : Alternative Method To decimal form 130-127 = 3 1.11110110000000000000000000 To decimal form 130-127 = 3 1.11110110000000000000000000 1 +.5 +.25 +.125 +.0625 + 0 +.015625 +.0078125 2 3 * 1.9609375 = 15.6875 ( negative ) - 15.6875 Shift Point ( negative ) 1111.10110000000000000000000-15.6875 Exercise Floating Point Conversion (2) Express 3.14 as a 32-bit floating point number : (Note: only use 10 significant bits for the mantissa) Exercise Floating Point Conversion (2) Express 3.14 as a 32-bit floating point number : 0 10000000 10010001111010111000010 Skip answer

Detail Solution : 3.14 to IEEE Simple Precision 3.14 To Binary: 11. 0010001111010111000010 Delete implied left-most 1 and normalize Poof! Exponent = 127 + 1 position point moved when normalized Value is positive: Sign bit = 0 10010001111010111000010 10000000 0 10000000 10010001111010111000010 IEEE Single-Precision Floating Point Format sign exponent f ract ion s ê f 1 f 2... f 23 0 1 8 9 31 ^e e Value Type 255 none none Infinity or NaN 254 127 (-1) s (1.f 1 f 2...) 2 127 Normalized............ 2-125 (-1) s (1.f 1 f 2...) 2-125 Normalized 1-126 (-1) s (1.f 1 f 2...) 2-126 Normalized 0-126 (-1) s (0.f 1 f 2...) 2-126 Denormalized Exponent bias is 127 for normalized #s Decimal Floating-Point Add and Subtract Examples Operands Alignment Normalize & round 6.144 10 2 0.06144 10 4 1.003644 10 5 +9.975 10 4 +9.975 10 4 +.0005 10 5 10.03644 10 4 1.004 10 5 Operands Alignment Normalize & round 1.076 10-7 1.076 10-7 7.7300 10-9 -9.987 10-8 -0.9987 10-7 +.0005 10-9 0.0773 10-7 7.730 10-9 Floating Point Calculations: Addition Numbers must be aligned: have the same exponent (the larger one, to protect precision) Add mantissas. If overflow, adjust the exponent Ex. 0 51 99718 (e = 1) and 0 49 67000 (e = -1) Align numbers: 0 51 99718 0 51 00670 Add them: 99718 + 00670 1 00388 Overflow Round the number and adjust exponent: 0 52 10039

Floating Point Calculations: Multiplication (a * 10^e) * (b * 10^f) = a * b * 10^(e+f) Rule: multiply mantissas; add exponents But: (n + e) + (n + f) = 2 * (n + e + f) Must subtract excess n from result Ex. 0 51 99718 (e = 1) and 0 49 67000 (e = -1) Mantissas:.99718 *.67000 = 0.6681106 Exponents: 51 + 49 = 100 and 100 50 = 50 Normalize:.6681106.66811 Final result:.66811 * 10 (since 50 means e = 0)