Computer Science 210 Computer Organization Floating Point Representation.

Slides:



Advertisements
Similar presentations
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
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.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Faculty of Computer Science © 2006 CMPUT 229 Floating Point Representation Operating with Real Numbers.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
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.
Booth’s Algorithm.
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Floating Point Numbers
Representing Real Numbers Using Floating Point Notation Lecture 6 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Lecture 8 Floating point format
Binary Representation and Computer Arithmetic
Simple Data Type Representation and conversion of numbers
Numbers and number systems
Ch. 2 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.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
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.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
16. Binary Numbers Programming in C++ Computer Science Dept Va Tech August, 1999 © Barnette ND, McQuain WD, Keenan MA 1 Binary Number System Base.
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Numbers in Computers.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
FLOATING-POINT NUMBER REPRESENTATION
CSCI206 - Computer Organization & Programming
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
A brief comparison of integer and double representation
Introduction To Computer Science
Number Systems and Binary Arithmetic
Data Representation Binary Numbers Binary Addition
Floating Point Math & Representation
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
IEEE floating point format
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
CSCI206 - Computer Organization & Programming
Number Representations
Data Representation Data Types Complements Fixed Point Representation
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
COMS 161 Introduction to Computing
Numbers with fractions Could be done in pure binary
Number Representations
Presentation transcript:

Computer Science 210 Computer Organization Floating Point Representation

Real Numbers Format 1:. Examples: 0.25, … Format 2 (normalized form):. × Example: 2.5 × In mathematics, infinite range and infinite precision (“uncountably infinite”)

math.pi >>> import math >>> math.pi >>> print(math.pi) >>> print("%.50f" % math.pi) Looks like about 48 places of precision (in base 10 )

IEEE Standard Single precision: 32 bits Double precision: 64 bits 2.5 × Reserve some bits for the significand (the digits to the left of ×) and some for the exponent (the stuff to the right of ×) Double precision uses 53 bits for the significand, 11 bits for the exponent, and one sign bit Approximate double precision range is to

IEEE Single Precision Format 32 bits Roughly (-1) S x F x 2 E F is related to the significand E is related to the exponent Rough range Small fractions 2 x Large fractions 2 x S Exponent Significand

Fractions in Binary In general, 2 -N = 1/2 N = 1 × 2 -1 = 1 × ½ = = 1 × 2 -2 = 1 × ¼ = = 1 × ½ + 1 × ¼ =

Decimal to Binary Conversion (Whole Numbers) While N > 0 do Set N to N/2 (whole part) Record the remainder (1 or 0) Set A to remainders in reverse order

Decimal to Binary - Example Example: Convert to binary N Rem N Rem =

Decimal to Binary - Fractions While N > 0 (or enough bits) do Set N to N*2 (whole part) Record the whole number part (1 or 0) Set N to fraction part Set bits to sequence of whole number parts (in order obtained)

Decimal fraction to binary - Example Example: Convert to binary N Whole Part =

Decimal fraction to binary - Example Example: Convert to binary N Whole Part = … 2

Round-Off Errors >>> >>> print("%.48f" % 0.1) >>> print("%.48f" % 0.25) >>> print("%.48f" % 0.3) Caused by conversion of decimal fractions to binary

Scientific Notation - Decimal Number Normalized Scientific x ,326,043, x 10 9

Floating Point IEEE Single Precision Standard (32 bits) Roughly (-1) S x F x 2 E –F is related to significand –E is related to exponent Rough range –Small fractions 2 x –Large fractions 2 x S Exponent Significand

Floating Point – Exponent Field This comes before significand for sorting purposes With 8 bit exponent range would be –128 to 127 Note: -1 would be and with simple sorting would appear largest. For this reason, we take the exponent, add 127 and represent this as unsigned. This is called bias 127. Then exponent field (255) would represent = 128. Also (0) would represent = Range of exponents is -127 to 128

Floating Point – Significand Normalized form: … x 2 E Hidden bit trick: Since the bit to left of binary point is always 1, why store it? We don’t. Number = (-1) S x (1+Significand) x 2 E-127

Floating Point Example: Convert to IEEE Step 1. Convert to binary: Step 2. Normalize: x 2 8 Step 3. Compute biased exponent in binary: = 135  Step 4. Write the floating point representation: or 439C7000 in hexadecimal

Floating Point Example: Convert IEEE … to decimal Step 1. Sign bit is 1; so number is negative Step 2. Exponent field is or 129; so actual exponent is 2 Step 3. Significand is …; so 1 + Significand is … Step 4. Number = (-1) S x (1+Significand) x 2 E-127 = (-1) 1 x (1.010) x 2 2 = -101 = -5