Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems

Slides:



Advertisements
Similar presentations
Introduction to Computer Systems
Advertisements

15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 1.7 Storing Fractions. Excess Notation, continued… In this notation, "m" indicates the total number of bits. For us (working with 8 bits), it.
1 CSE1301 Computer Programming Lecture 30: Real Number Representation.
CSE1301 Computer Programming Lecture 33: Real Number Representation
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.
Floating Point Numbers
Representing Real Numbers Using Floating Point Notation Lecture 6 CSCI 1405, CSCI 1301 Introduction to Computer Science Fall 2009.
1 Error Analysis Part 1 The Basics. 2 Key Concepts Analytical vs. numerical Methods Representation of floating-point numbers Concept of significant digits.
Representation and Conversion of Numeric Types 4 We have seen multiple data types that C provides for numbers: int and double 4 What differences are there.
Number Representation Rizwan Rehman, CCS, DU. Convert a number from decimal to binary notation and vice versa. Understand the different representations.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
The IEEE Format for storing float (single precision) data type Use the “enter” key to proceed through the show.
Lecture 8 Floating point format
Simple Data Type Representation and conversion of numbers
Numbers and number systems
Data Representation – Binary Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Computer Science 111 Fundamentals of Programming I Number Systems.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
Computer Architecture
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
Computer Science Engineering B.E.(4 th sem) c omputer system organization Topic-Floating and decimal arithmetic S ubmitted to– Prof. Shweta Agrawal Submitted.
9.4 FLOATING-POINT REPRESENTATION
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 3 Number Representation. Convert a number from decimal to binary notation and vice versa. Understand the different representations of an integer.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
6 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
CSC 221 Computer Organization and Assembly Language
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
29 September 2015Birkbeck College, U. London1 Introduction to Computer Systems Department of Computer Science and Information Systems Autumn 2015 Preliminary.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
IEEE Arithmetic UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Computer Architecture Lecture 22 Fasih ur Rehman.
Department of Management School of Business, Economics and Informatics Binary Numbers 2 Eva Szatmari
Floating Point in Binary 1.Place Value Chart:
20 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
13 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Floating Point Binary A2 Computing OCR Module 2509.
CS 160 Lecture 4 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Starter Using two’s Complement form convert the following from Denary to Binary using 8 bits. Answer on mini whiteboard Using two’s.
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Introduction To Computer Science
Floating Point Number system corresponding to the decimal notation
April 2006 Saeid Nooshabadi
A Level Computing Component 2
Data Structures Mohammed Thajeel To the second year students
EEL 3705 / 3705L Digital Logic Design
Number Representation
Storing Integers and Fractions
COMS 161 Introduction to Computing
OBJECTIVES After reading this chapter, the reader should be able to :
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems Autumn 2015 Week 3b: Floating Point Notation for Binary Fractions 13 October 2015

Binary Fractions 13 October 2015Birkbeck College, U. London2

Properties of Binary Fractions 1  Multiply by 2: move the radix point one place to the right, e.g. 1.01x2 = 10.1  Divide by 2: move the radix point one place to the left, e.g. 1.02÷2 = October 2015Birkbeck College, U. London3

Properties of Binary Fractions 2  A number can be specified exactly by a binary fraction if and only if it has the form integer/power of 2  E.g specifies the decimal fraction 5/ …. specifies 1/3 13 October 2015Birkbeck College, U. London4

Brookshear, Section 1.75 Specification of a Binary Fraction The binary fraction has three parts: The sign – The position of the radix point The bit string October 2015

Brookshear, Section 1.76 Binary Fraction and Powers of 2 13 October = 5+(25/32)

Brookshear, Section 1.77 Reconstruction of a Binary Fraction The sign is + The position of the radix point is just to the right of the second bit from the left The bit string is What is the binary fraction? 13 October 2015

Brookshear, Section 1.78 Summary To represent a binary fraction three pieces of information are needed: Sign Position of the radix point Bit string

Spacing Between Numbers 13 October 2015Birkbeck College, U. London9 Two’s complement: equally spaced numbers 0 Floating point: big gaps between big numbers, small gaps between small numbers. 0

The Key: Exponents 13 October 2015Birkbeck College, U. London /16 1/8 ¼ ½ big gaps between big numbers small gaps between small numbers

Brookshear, Section Standard Form for a Binary Fraction  Any non-zero binary fraction can be written in the form ±2 r x 0.t where t is a bit string beginning with 1.  Examples = +2 2 x = x October 2015

Brookshear, Section Floating Point Representation Write a non-zero binary fraction in the form ± 2 r x 0.t Record the sign – bit string s1 Record r – bit string s2 Record t – bit string s3 Output s1||s2||s3 13 October 2015

Brookshear, Section Floating Point Notation 8 bit floating point: se1e2e3m1m2m3m4 sign exponent mantissa 1 bit 3 bits 4 bits radix r bit string t The exponent is in 3 bit excess notation

13 October 2015Brookshear, Section To Find the Floating Point Notation Write the non-zero number as ± 2 r x 0.t If sign = -1, then s1=1, else s1=0. s2 = 3 bit excess notation for r. s3= leftmost four bits of t.

13 October 2015Birkbeck College, U. London15 Example b= s=1 b= x exponent = -2, s2 =010 Floating point notation

13 October 2015Birkbeck College, U. London16 Second Example Floating point notation: s1=1, therefore negative. s2 = 011, exponent=-1 s3 = 1100 Binary fraction = -3/8

Birkbeck College, U. London17 Class Examples Find the floating point representation of the decimal number -1 1/8 Find the decimal number which has the floating point representation October 2015

Brookshear, Section Round-Off Error 2+5/8= ½ = The 8 bit floating point notations for 2 5/8 and 2 ½ are the same: The error in approximating 2+5/8 with is round-off error or truncation error.

Floating Point Addition of Numbers x, y a = floating point number nearest to x b = floating point number nearest to y c=a+b z=floating point number nearest to c 13 October 2015Birkbeck College, U. London19

13 October 2015Birkbeck College, U. London20 Examples of Floating Point Addition 2 ½: /8: ¼: ¾: /8)=2 1/4=2 ¾ (2 1/8=2 1/8=2 ½

13 October 2015Birkbeck College, U. London21 Round-Off in Decimal and Binary 1/5=0.2 exactly in decimal notation 1/5= ….. in binary notation 1/5 cannot be represented exactly in binary floating point no matter how many bits are used. Round-off is unavoidable but it is reduced by using more bits.

Birkbeck College, U. London22 Floating Point Errors Overflow: number too large to be represented. Underflow: number <>0 and too small to be represented. Invalid operation: e.g. SquareRoot[-1]. See 13 October 2015

Birkbeck College, U. London23 IEEE Standard for Floating Point Arithmetic For a general discussion of fp arithmetic see 01…89…31 Sign s bit 0 Exponent e bits 1-8 Mantissa m bits 9-31 If 0<e<255, then value = (-1) s x 2 e-127 x 1.m If e=0, s=0, m=0, then value = 0 If e=0, s=1, m=0, then value = -0 Single precision, 32 bits. 13 October 2015

Numbers in Computing 13 October 2015Birkbeck College, U. London24 q = 0.1 The value stored in the memory location q is not 0.1! E.g. in Python the value stored is See