Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise.

Slides:



Advertisements
Similar presentations
Scientific Notation.
Advertisements

COMP2130 Winter 2015 Storing signed numbers in memory.
DATA REPRESENTATION Y. Colette Lemard February
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Floating Point Numbers
1 IEEE Floating Point Revision Guide for Phase Test Week 5.
Floating Point Numbers
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.
Chapter 5 Floating Point Numbers. Real Numbers l Floating point representation is used whenever the number to be represented is outside the range of integer.
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.
Floating Point Numbers
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 Number Systems.
The Binary Number System
Simple Data Type Representation and conversion of numbers
Scientific Notation.
Scientific Notation Recognize and use scientific notation.
Scientific Notation. What is scientific Notation? Scientific notation is a way of expressing really big numbers or really small numbers. It is most often.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
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.
The Teacher CP4 Binary and all that… CP4 Revision.
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.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Floating Point Arithmetic
Introduction to Number System
Fractions in Binary.
Scientific notation is a way of expressing really big numbers or really small numbers. Scientific notation is a way of expressing really big numbers or.
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Number Systems & Operations
Floating Point in Binary 1.Place Value Chart:
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Scientific Notation to Standard Notation Positive and Negative Exponents.
Georgia Institute of Technology Introduction to Programming Part 3 Barb Ericson Georgia Institute of Technology May 2006.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
Binary & Normalization What is Normalization? We discussed this the other day (special review session slides, near the end) Can someone tell us.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Lesson Objectives Aims You should know about: Binary numbers ‘n’ that.
Floating Point Numbers
Nat 4/5 Computing Science Lesson 1: Binary
Floating Point Representations
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Data Representation Covering… Binary addition / subtraction
Objectives Today: P4 Data Types – Floating Points P4 Variable Quiz P3 Iteration and Selection Practical Are you logged on? Then come around the table Unit.
Binary Fractions.
Convert scientific notation to standard notation
Introduction To Computer Science
Recap Add these numbers together in binary
A Level Computing Component 2
Integers in 2’s compliment Floating point
CSCI206 - Computer Organization & Programming
Starter Using the fingers on only one hand, what is the highest number you can count to? Rules: You must start at 1 You must count sequentially (i.e.
Normalised Floating Point Numbers
COMS 161 Introduction to Computing
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Presentation transcript:

Learning Objectives 3.3.1f - Describe the nature and uses of floating point form 3.3.1h - Convert a real number to floating point form Learn how to normalise a floating point binary numbers Learn why we want to normalise floating point

Floating Point Denary 1.637 x 105 Recall Mantissa and Exponent Start with 1.637 Shift point 5 places to the right. 163700. What base will we use for binary?

Shift point 5 places to the right. Floating Point Binary Recall Mantissa and Exponent 0.10100111 x 25 Start with 0.10100111 Shift point 5 places to the right. 10100.111

Converting Binary Floating Point to Decimal 20 and 7/8 10100.111

Floating Point Representation 2’s complement is used for negatives Recall Mantissa and Exponent • 1 Markout Exponent, Mantissa, and Decimal Sign Bit is Positive on exponent and mantissa Convert Exponent Positive exponent means shift decimal in mantissa +4 right Convert to decimal 0.101100100 000100 Positive Numbers +4 01011.00100 8+2+1 + 1/8 = 11.125d

Negative Exponent 1 • 2’s complement is used Markout Exponent, Mantissa, and Decimal Sign Bit is Negative on exponent and mantissa means 2’s complement numbers Convert Exponent From 2’s Complement But Remember It’s Negative Convert Mantissa From 2’s Complement But Remember It’s Negative Shift decimal -4 places means left Convert to decimal, Remember it’s negative 1.100110000 111100 Negative Numbers -000100 = -4 -0.011010000 -0.0000011010000 -1/64 + 1/128 + 1/512 = -0.025390625

1100111000001000 (6-bit exp) Mark Out Determine Signs 1.100111000 | 001000 Determine Signs Exponent is positive; Mantissa is negative Convert Exp to decimal; Remember sign Convert 2s complement +8 If mantissa is negative, convert it; Remember sign Convert 2s complement  -0.011001000 Shift mantissa -0.011001000  001100100.0 Convert mantissa; Remember sign 4+32+64 -100

Your Turn 8-bit mantissa, 4-bit exponent 2s complement, Normalised 1.001 0111 0100 -13.125 0.100 0000 1110 0.125 1.011 1111 0010 -2.03125 1.000 1100 0100 -14.5

Normalisation 10100.111 Move That Decimal 1.0100111

Big Problem Normalisation is the way around this. 0.100000000 000010 0.100000000 x 22 2 0.010000000 000011 0.010000000 x 23 2 0.001000000 000100 0.001000000 x 24 2 If we let any number of leading 0s in and adjust the exponent we get multiple ways to represent the same number.  If we have more than 1 way to represent a number it reduces the "pool" of possible numbers we can represent. Normalisation is the way around this.

Another Big Problem Normalisation is the way around this. 0.100000000 000010 0.100000000 x 22 2 Let’s add in some number of leading 0s and adjust the exponent. 0.000100000101  000101 We also have to drop the 101 off the end because we don't have enough bits to store it.  0.000100000  000101 We've reduced the precision of our number. Normalisation is the way around this.

Normalisation Ensures only 1 way to represent each number Ensures maximum range available Normalised numbers always begin with two bits that are different You may have to move the decimal yourself and adjust the exponent accordingly. Positive Numbers 0.1 Negative Numbers 1.0

Normalised Good (Normalised) Bad (Unnormalised) 0.100110011 110001 0.100110011 110001 1.001100111 110010 Bad (Unnormalised) 0.001101001 100111 1.110001101 010011 10 bit mantissa, 6 bit exponent Normalised begin with different patterns Remember, may need to change your exponent to make it normalised

Your Turn 0.001101001 100111 Exponent is negative, convert it back to decimal 011001 = 25 (negative) Move decimal to normalised location 0.110100100 To get back to original location, I have to move decimal -2 places -25 + -2 = -27 is the new exponent 011011  2s comp 100101 Float = 0.110100100 100101

Your Turn 1.110001101 010011 Exponent is positive, convert it back to decimal 010011 = 19 (positive) Move decimal to normalised location 1.000110100 To get back to original location, I have to move decimal -2 places 19 + -2 = 17 is the new decimal 100010 Float = 1.000110100 100010

Converting Fractions to Binary

Convert Fractions to Binary This is a simple algorithm for converting fractional parts of numbers to binary Put the fraction into decimal format Multiply by 2 If the whole number part of result is 0, then binary digit is 0; if the whole number part of result is 1, then binary digit is 1 Mod the result (take the fractional part only) Keep going until you get 0 as a result or fill all of your binary digit slots

.011110 Fill in with following 0s to number of bits you need Example 15/32 = 0.46875 .01111 Multiply Result Binary 0.46875 x 2 0.93750 0.93750 x 2 1.8750 1 .8750 x 2 1.75 .75 x 2 1.5 .5 x 2 1.0 .011110 Fill in with following 0s to number of bits you need

Converting Decimal to Binary Floating Point (The Whole Thing Together)

Given a Decimal Number BinInteger = Convert integer part of number to binary BinFraction = Convert fractional part of number to binary If decimal number is negative BinInteger = 2s complement of BinInteger BinFraction = 2s complement of BinFraction NonNormalFloat = write BinInteger + “.” + BinFraction NormalFloat = Normalise NonNormalFloat Exponent = Count decimal movement & determine sign Convert Exponent to binary If Exponent is negative Exponent = 2s complement of Exponent If NormalFloat has empty slots Fill with 0s on right If Exponent has empty slots Fill with 0s if positive or 1s if negative on left Answer = NormalFloat join Exponent

Full Example: -27.625 10-bit Mantissa 6-bit Exponent 0000011011 BinInteger = Convert integer part of number to binary BinFraction = Convert fractional part of number to binary If decimal number is negative BinInteger = 2s complement of BinInteger BinFraction = 2s complement of BinFraction NonNormalFloat = write BinInteger + “.” + BinFraction NormalFloat = Normalise NonNormalFloat Exponent = Count decimal movement & determine sign Convert Exponent to binary If Exponent is negative Exponent = 2s complement of Exponent If NormalFloat has empty slots Fill with 0s on right If Exponent has empty slots Fill with 0s if positive or 1s if negative on left Answer = NormalFloat join Exponent 0000011011 .101 Yes 1111100101 .011 1111100101.011 1.00101011 +5 101 1.001010110 101000 1001010110101000

Homework Assume 6-bit exponent, 10-bit mantissa, 2s complement, normalised form Convert to decimal 0101000000111111 0001101000000110 1101000000111111 1001101000000110

Homework Assume 10-bit mantissa, 6-bit exponent, 2s complement. Convert to normalised floating point 123 0.1875 -15/32