Ch. 2 Floating Point Numbers

Slides:



Advertisements
Similar presentations
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
Advertisements

Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Lecture - 2 Number systems and computer data formats
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Datorteknik FloatingPoint bild 1 Floating point Number system corresponding to the decimal notation 1,837 * 10 significand exponent a great number of corresponding.
Floating Point Numbers
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Floating Point Numbers. CMPE12cCyrus Bazeghi 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or 2 64.
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
Floating Point Numbers
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
Lecture 8 Floating point format
Simple Data Type Representation and conversion of numbers
Information Representation (Level ISA3) Floating point numbers.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Computing Systems Basic arithmetic for computers.
Computer Architecture
ECE232: Hardware Organization and Design
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Floating Point Representations CDA 3101 Discussion Session 02.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic.
1 COMS 161 Introduction to Computing Title: Numeric Processing Date: November 08, 2004 Lecture Number: 30.
Computer Organization and Design Information Encoding II Montek Singh Wed, Aug 29, 2012 Lecture 3.
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.
CS 61C L3.2.1 Floating Point 1 (1) K. Meinz, Summer 2004 © UCB CS61C : Machine Structures Lecture Floating Point Kurt Meinz inst.eecs.berkeley.edu/~cs61c.
Number Systems & Operations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Numbers in Computers.
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.
Floating Point Representations
Computer Science 210 Computer Organization
Floating Point Representations
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
Topic 3d Representation of Real Numbers
Luddy Harrison CS433G Spring 2007
CSCI206 - Computer Organization & Programming
Number Representations
CSCI206 - Computer Organization & Programming
Computer Science 210 Computer Organization
COMS 361 Computer Organization
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Floating Point Numbers
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
Number Representations
Presentation transcript:

Ch. 2 Floating Point Numbers Representation Comp Sci 251 -- Floating point

Floating point numbers Binary representation of fractional numbers IEEE 754 standard Comp Sci 251 -- Floating point

Binary  Decimal conversion 23.47 = 2×101 + 3×100 + 4×10-1 + 7×10-2 decimal point 10.01two = 1×21 + 0×20 + 0×2-1 + 1×2-2 binary point = 1×2 + 0×1 + 0×½ + 1×¼ = 2 + 0.25 = 2.25 Comp Sci 251 -- Floating point

Decimal  Binary conversion Write number as sum of powers of 2 0.8125 = 0.5 + 0.25 + 0.0625 = 2-1 + 2-2 + 2-4 = 0.1101two Algorithm: Repeatedly multiply fraction by two until fraction becomes zero. 0.8125  1.625 0.625  1.25 0.25  0.5 0.5  1.0 Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Beware Finite decimal digits  finite binary digits Example: 0.1ten  0.2  0.4  0.8  1.6  1.2  0.4  0.8  1.6  1.2  0.4 … 0.1ten = 0.00011001100110011…two = 0.00011two (infinite repeating binary) The more bits, the binary rep gets closer to 0.1ten Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Scientific notation Decimal: -123,000,000,000,000  -1.23 × 1014 0.000 000 000 000 000 123  +1.23× 10-16 Binary: 110 1100 0000 0000  1.1011× 214 -0.0000 0000 0000 0001 1011  -1.1101 × 2-16 Comp Sci 251 -- Floating point

Floating point representation Three pieces: sign exponent significand Format: Fixed-size representation (32-bit, 64-bit) 1 sign bit more exponent bits  greater range more significand bits  greater accuracy sign exponent significand Comp Sci 251 -- Floating point

IEEE 754 floating point standards Single precision (32-bit) format Normalized rule: number represented is (-1)S×1.F×2E-127, E (≠ 00…0 or 11…1) Example: +101101.101+1.01101101×25 1 8 23 S E F Actual exponent = 5 = E – 127 E = 5 + 127 = 132 Convert 13210 to binary => 10000100 1000 0100 0110 1101 0000 0000 0000 000 Comp Sci 251 -- Floating point

Features of IEEE 754 format Sign: 1negative, 0non-negative Significand: Normalized number: always a 1 left of binary point (except when E is 0 or 255) Do not waste a bit on this 1  "hidden 1" Exponent: Not two's-complement representation Unsigned interpretation minus bias Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Example: 0.75 0.75 ten = 0.11 two = 1.1 x 2 -1 1.1 = 1. F → F = 1 E – 127 = -1 → E = 127 -1 = 126 = 01111110two S = 0 00111111010000000000000000000000 = 0x3F400000 Comp Sci 251 -- Floating point

Example 0.1ten - Check float.a 0.1ten = 0.00011two = 1.10011two x 2 -4 = 1.F x 2 E-127 F = 10011 -4 = E – 127 E = 127 -4 = 123 = 01111011two 00111101110011001100110011001100110011 0x3DCCCCCD, why D at the least signif digit? Comp Sci 251 -- Floating point

IEEE Double precision standard E not 00…0 (decimal 0) or 11…1(decimal 2047) Normalized rule: number represented is (-1)S×1.F×2E-1023 1 11 52 S E F Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Special-case numbers Problem: hidden 1 prevents representation of 0 Solution: make exceptions to the rule Bit patterns reserved for unusual numbers: E = 00…0 E = 11…1 Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Special-case numbers Zeroes:  +0  -0 Infinities:  +∞  -∞ 00…0 00…0 1 00…0 00…0 11…1 00…0 1 11…1 00…0 Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point Denormalized numbers No hidden 1 Allows numbers very close to 0 E = 00…0  Different interpretation applies Denormalization rule: number represented is (-1)S×0.F×2-126 (single-precision) (-1)S×0.F×2-1022 (double-precision) Note: zeroes follow this rule Not a Number (NaN): E = 11…1; F != 00…0 Comp Sci 251 -- Floating point

Comp Sci 251 -- Floating point IEEE 754 summary E = 00…0, F = 00…0  0 E = 00…0, F ≠ 00…0  denormalized 00…00 < E < 11…1  normalized E = 11…1 F = 00…0  infinities F ≠ 00…0  NaN Comp Sci 251 -- Floating point