Lecture 8 Floating point format

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

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.
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
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
Number Systems Standard positional representation of numbers:
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
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)
Computer Science 210 Computer Organization Floating Point Representation.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
Binary Representation and Computer Arithmetic
The Binary Number System
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Ch. 2 Floating Point 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.
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
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.
Computing Systems Basic arithmetic for computers.
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.
COMPSCI 210 Semester Tutorial 1
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
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
9.4 FLOATING-POINT REPRESENTATION
Binary Fractions. Fractions A radix separates the integer part from the fraction part of a number Columns to the right of the radix have negative.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.6 Instructor: Lin Chen Sept 2013.
CEC 220 Digital Circuit Design Binary Codes
Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Floating Point Numbers
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Computer Science 210 Computer Organization
Introduction To Computer Science
Floating Point Number system corresponding to the decimal notation
Data Representation Data Types Complements Fixed Point Representation
Computer Science 210 Computer Organization
Storing Integers and Fractions
Floating Point Numbers
COMS 161 Introduction to Computing
Presentation transcript:

Lecture 8 Floating point format ITEC 352 Lecture 8 Floating point format

Review Two’s complement Excessive notation Introduction to floating point

Outline Floating point conversion process

Standards What are the components that make up a floating point number? How would you represent each piece in binary?

Why? Consider class floatTest { public static void main(String[] args) double x = 10; double y=Math.sqrt(x); y = y * y; if (x == y) System.out.println("Equal"); else System.out.println("Not equal"); }

Normalization .254 * 10-1 254 can be represented as: 2.54 * 102 25.4 * 101 .254 * 10-1 There are infinitely many other ways, which creates problems when making comparisons, with so many representations of the same number. • Floating point numbers are usually normalized, in which the radix point is located in only one possible position for a given number. • Usually, but not always, the normalized representation places the radix point immediately to the left of the leftmost, nonzero digit in the fraction, as in: .254X 103.

Example • Represent .254X 103 in a normalized base 8 floating point format with a sign bit, followed by a 3-bit excess 4 exponent, followed by four base 8 digits. • Step #1: Convert to the target base. .254X103 = 25410. Using the remainder method, we find that 25410 = 376X80: 254/8 = 31 R 6 31/8 = 3 R 7 3/8 = 0 R 3 • Step #2: Normalize: 376X80 = .376X83. • Step #3: Fill in the bit fields, with a positive sign (sign bit = 0), an exponent of 3 + 4 = 7 (excess 4), and 4-digit fraction = .3760: 0 111 . 011 111 110 000

Example Convert (9.375 * 10-2)10 to base 2 scientific notation • Start by converting from base 10 floating point to base 10 fixed point by moving the decimal point two positions to the left, which corresponds to the -2 exponent: .09375. • Next, convert from base 10 fixed point to base 2 fixed point: .09375 * 2 = 0.1875 .1875 * 2 = 0.375 .375 * 2 = 0.75 .75 * 2 = 1.5 .5 * 2 = 1.0 • Thus, (.09375)10 = (.00011)2. • Finally, convert to normalized base 2 floating point: .00011 = .00011 * 20 = 1.1 * 2-4

IEEE 754 standard Defines how to represent floating point numbers in 32 bit (single precision) and 64 bit (double precision). 32 bit is the “float” type in java. 64 bit is the “double” type in java. The method: doubleToLong in Java displays the floating point number in IEEE standard.

IEEE 754 standard also considers the following numbers: Considerations IEEE 754 standard also considers the following numbers: Negative numbers. Numbers with a negative exponent. It also optimizes representation by normalizing the numbers and using the concept of hidden “1”

Hidden “1” What is the normalized representation of the following: 0.00111 1.00010 100.100

Hidden “1” What is the normalized representation of the following: 0.00111 = 1.11 * 2-3 1.00010 = 1.00 * 20 100.100 = 1.00 * 22 Common theme: the digit to the left of the “.” is always 1!! So why store this in 32 or 64 bits? This is called the hidden 1 representation.

IEEE 754 representation uses the following conventions: Negative thoughts IEEE 754 representation uses the following conventions: Negative significand – use sign magnitude form. Negative exponent use excess 127 for single precision.

IEEE-754 Floating Point Formats

IEEE-754 Examples

IEEE-754 Conversion Example • Represent -12.62510 in single precision IEEE-754 format. • Step #1: Convert to target base. -12.62510 = - 1100.1012 • Step #2: Normalize. -1100.1012 = -1.1001012 * 23 • Step #3: Fill in bit fields. Sign is negative, so sign bit is 1. Exponent is in excess 127 (not excess 128!), so exponent is represented as the unsigned integer 3 + 127 = 130. Leading 1 of significand is hidden, so final bit pattern is: 1 1000 0010 . 1001 0100 0000 0000 0000 000

BCD representation uses 4 digits. Binary coded decimals Many systems still use decimal’s for computation, e.g., older calculators. Representation of decimals in such devices: Use binary numbers to represent them (called Binary coded decimals) BCD representation uses 4 digits. 0 = 0000 9 = 1001

Summary IEEE floating point