1 IEEE Floating Point Revision Guide for Phase Test Week 5.

Slides:



Advertisements
Similar presentations
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Advertisements

Floating Point Numbers
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
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.
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.
Lecture 3 Number Representation 2 This week – Recap Addition – Addition circuitry – Subtraction of integers in binary – Representing numbers with fractional.
Number Systems Standard positional representation of numbers:
Signed 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
Floating Point Numbers
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…
Binary Number Systems.
School of Computer Science G51CSA 1 Computer Arithmetic.
The Binary Number System
Data Representation Number Systems.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Representation of Data Ma King Man. Reference Text Book: Volume 2 Notes: Chapter 19.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Numbers in Computers.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
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.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Lesson Objectives Aims You should know about: Binary numbers ‘n’ that.
Floating Point Numbers
Floating Point Representations
Fundamentals of Computer Science
Introduction To Computer Science
William Stallings Computer Organization and Architecture 7th Edition
Chapter 5 Data representation.
Luddy Harrison CS433G Spring 2007
Number Representations
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Numbers with fractions Could be done in pure binary
Number Representations
Presentation transcript:

1 IEEE Floating Point Revision Guide for Phase Test Week 5

2 Floating Point could be represented as * * A calculator might display 159 E * MantissaExponent

3 Binary The value of real binary numbers… Scientific Fractions. ½¼¾ Decimal = 4+1+1/2+1/8 = = = 5 ⅝

4 Binary Fractions The value of real binary numbers… Scientific Fractions. ½¼⅛ Decimal = 4+1+1/2+1/8 = = = 5 ⅝

5 Binary Fractions The value of real binary numbers… Scientific Fractions. ½¼⅛ Decimal = 4+1+1/2+1/8 = = = 5 ⅝

6 IEEE Single Precision The number will occupy 32 bits The first bit represents the sign of the number; 1= negative 0= positive. The next 8 bits will specify the exponent stored in biased 127 form. The remaining 23 bits will carry the mantissa normalised to be between 1 and 2. i.e. 1<= mantissa < 2

7 Basic Conversion Converting a decimal number to a floating point number. 1.Take the integer part of the number and generate the binary equivalent. 2.Take the fractional part and generate a binary fraction 3.Then place the two parts together and normalise.

8 IEEE – Example 1 Convert 6.75 to 32 bit IEEE format. 1.The Mantissa. The Integer first. 6 / 2 = 3 r 0 3 / 2= 1 r 1 1 / 2= 0 r 1 2. Fraction next..75 * 2 = * 2 = put the two parts together… Now normalise * 2 2 = =

9 IEEE – Example 1 Convert 6.75 to 32 bit IEEE format. 1.The Mantissa. The Integer first. 6 / 2 = 3 r 0 3 / 2= 1 r 1 1 / 2= 0 r 1 2. Fraction next..75 * 2 = * 2 = put the two parts together… Now normalise * 2 2 = 110 2

10 IEEE – Example 1 Convert 6.75 to 32 bit IEEE format. 1.The Mantissa. The Integer first. 6 / 2 = 3 r 0 3 / 2= 1 r 1 1 / 2= 0 r 1 2. Fraction next..75 * 2 = * 2 = put the two parts together… Now normalise * 2 2 = =

11 IEEE Biased 127 Exponent To generate a biased 127 exponent Take the value of the signed exponent and add 127. Example then = and my value for the exponent would be 143 = So it is simply now an unsigned value....

12 Possible Representations of an Exponent

13 Why Biased ? The smallest exponent Only one exponent zero The highest exponent is To increase the exponent by one simply add 1 to the present pattern.

14 Back to the example Our original example revisited… * 2 2 Exponent is =129 or in binary. NOTE: Mantissa always ends up with a value of ‘1’ before the Dot. This is a waste of storage therefore it is implied but not actually stored is stored in 32 bit floating point IEEE representation: sign(1) exponent(8) mantissa(23)

15 Special cases 0 + Infinity and - infinity.  Zero is a pattern that only contains ‘0’s  Positive Infinity is the pattern ….  Negative Infinity is the pattern ….

16 Truncation and Rounding Following arithmetic operations on a floating point number we may have increased the number of mantissa bits. Since we will have a fixed storage (23 places) for the mantissa we require to limit these bits. The simplest approach is to truncate the result prior to storage Example stored in 4 bits stored in 4 bits => ( loss )

17 Rounding If lost digit is > ½ then add 1 to LSB Example – in 4 bits < = ( rounded UP) < ( rounded DOWN) NOTE: Rounding is always preferred to truncation partly because it is intrinsically more accurate, and because we end up with a FAIR error.

18 Other Considerations Truncation always undervalues the result, and can lead to a systematic error situation. Rounding has one major disadvantage since it requires up to two further arithmetic operations. Note. When we use floating point care has to be taken when comparing the size of numbers because we are generating binary fractions of a predefined length. There is always going to be the chance of recurring numbers etc like 1/3 in decimal etc..

19 From Floating Point Binary to Decimal Example Sign = 1 therefore this number is a negative number. Exponent = = 123 subtract the 127 = - 4 Mantissa = * ve /16 + 1/32 +1/64+1/128+1/8192 or

20 Floating Point Maths Floating point addition and subtraction. 1. Make sure that the two numbers are of the same magnitude. Their Exponents have to be equal. 2. We then add or subtract the mantissas 3. Starting with the existing exponent re-normalise if needed.

21 Example Example 1.1* * 2 2 Select the smaller number and make the mantissa smaller by moving the point whilst increasing the exponent until the exponents match. 1.1 * * 2 3 Add the mantissas Re-normalise.

22 Example 1.1* * Re normalise * 2 3 = * 2 4

23 FP math Floating Point Multiplication Assume two numbers a x 2 m b x 2 n Result (a x 2 m ) x (b x 2 n ) = ( a x b ) x ( 2 m+n ) Floating Point Division Assume two number a x 2 m and b x 2 n Result (a x 2 m ) / (b x 2 n ) = (a/b ) x 2 m-n