Introduction to Computer Systems

Slides:



Advertisements
Similar presentations
Research Methods Lecturer: Steve Maybank
Advertisements

8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Department of Computer Science and Information Systems Autumn 2013 Preliminary.
22 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
11 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
18 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
15 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
8 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Introduction to Programming
25 March 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
8 February 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
25 January 2013Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems.
29 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)
A Simple ALU Binary Logic.
Fixed-point and floating-point numbers CS370 Fall 2003.
COMP3221 lec19-fp-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 19 : Floating Point Number Representation – I
Nat 4/5 Computing Science Lesson 1: Binary
Finite State Machines Finite state machines with output
1 CSE1301 Computer Programming Lecture 30: Real Number Representation.
Major Numeric Data Types Unsigned Integers Signed Integer Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
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.  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
Simple Data Type Representation and conversion of numbers
Numbers and number systems
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Computer Arithmetic Nizamettin AYDIN
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.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Information Representation: Negative and Floating Point.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
IT253: Computer Organization
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
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
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.
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
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Information Representation: Floating Point Representation.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Birkbeck 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.
Tokens in C  Keywords  These are reserved words of the C language. For example int, float, if, else, for, while etc.  Identifiers  An Identifier is.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
COMPUTER SCIENCE Data Representation and Machine Concepts Section 1.7 Instructor: Lin Chen Sept 2013.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Floating Point Numbers
Fundamentals of Computer Science
A Level Computing Component 2
Data Structures Mohammed Thajeel To the second year students
How to represent real numbers
Dr. Clincy Professor of CS
Prof. Giancarlo Succi, Ph.D., P.Eng.
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
COMS 161 Introduction to Computing
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems sjmaybank@dcs.bbk.ac.uk Autumn 2013 Week 4a: Floating Point Notation for Binary Fractions 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London Recap: Binary Numbers In the standard notation for binary numbers a string of binary digits such as 1001 stands for a sum of powers of 2: 1x23+0x22+0x21+1x20 Binary[1001] and Decimal[9] are different names for the same number 22 October 2013 Birkbeck College, U. London

Recap: Binary Addition column: 3 2 1 0 1 0 0 1 1 1 ===== 1 1 0 0 There is a carry from column 0 to column 1 and from column 1 to column 2. In tests or examinations, always show the carries. 22 October 2013 Brookshear, Section 1.5

Recap: Two’s Complement Two’s complement representations can be added as if they were standard binary numbers. -3 1101 2 0010 == ==== -1 1111 22 October 2013 Brookshear, Section 1.6

Birkbeck College, U. London Numbers in Computing cells in table: all numbers *: numbers that can be stored in memory #: numbers that can be referred to in a program * # *# Example: 0.1 cannot be stored in memory in IEEE double precision floating point, but the following is a correct Java statement t = 0.1; 22 October 2013 Birkbeck College, U. London

Spacing Between Numbers Two’s complement: equally spaced numbers Floating point: big gaps between big numbers, small gaps between small numbers. 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London The Key: Exponents -4 -3 -2 -1 0 1 2 3 2-4 2-3 2-2 2-1 20 21 22 23 1/16 1/8 ¼ ½ 1 2 4 8 big gaps between big numbers small gaps between small numbers 22 October 2013 Birkbeck College, U. London

Example of a Binary Fraction -101.11001 The binary fraction has three parts: The sign – The position of the radix point The bit string 10111001 22 October 2013 Brookshear, Section 1.7

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 101101 What is the binary fraction? 22 October 2013 Brookshear, Section 1.7

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

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

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

Floating Point Notation 8 bit floating point: s e1 e2 e3 m1 m2 m3 m4 sign exponent mantissa 1 bit 3 bits 4 bits radix r bit string t The exponent is in 3 bit excess notation 22 October 2013 Brookshear, Section 1.7

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

Birkbeck College, U. London Example b= - 0.00101011101 s=1 b= -2-2 x 0.101011101 exponent = -2, s2 =010 Floating point notation 10101010 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London Second Example Floating point notation: 10111100 s1=1, therefore negative. s2 = 011, exponent=-1 s3 = 1100 Binary fraction -0.011 = -3/8 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London Class Examples Find the floating point representation of the decimal number -1 1/8 Find the decimal number which has the floating point representation 01101101 22 October 2013 Birkbeck College, U. London

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

Floating Point Addition Let [x] be the floating point number closest to the number x. Floating point addition, x@y is defined by x@y=[[x]+[y]] Each operation w |-> [w] may introduce round off. 22 October 2013 Birkbeck College, U. London

Examples of Floating Point Addition 2 ½: 01101010 1/8: 00101000 ¼: 00111000 2 ¾: 01101011 2 ½ @(1/8 @ 1/8)=2 ½ @ 1/4=2 ¾ (2 ½ @ 1/8) @ 1/8=2 ½ @ 1/8=2 ½ 22 October 2013 Birkbeck College, U. London

Round-Off in Decimal and Binary 1/5=0.2 exactly in decimal notation 1/5=0.0011001100110011….. 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. 22 October 2013 Birkbeck College, U. London

Size of Round-Off Error E(x) E(x)/x≈α where α is constant. If x > 0, y > 0 and |x-y|<α x, then x-y cannot be found accurately using floating point arithmetic. 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London Examples 4 1/4: 100.01, fpoint = 01111000 4: 100.00, fpoint = 01111000 4 ¼-4 -> fpoint = 00000000 ½: 0.1, fpoint = 01001000 ¼: 0.01, fpoint = 00111000 ½-¼ -> fpoint = 00111000 22 October 2013 Birkbeck College, U. London

Birkbeck College, U. London 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 http://en.wikipedia.org/wiki/Floating_point 22 October 2013 Birkbeck College, U. London

IEEE Standard for Floating Point Arithmetic Single precision, 32 bits. 1 … 8 9 31 Mantissa m bits 9-31 Sign s bit 0 Exponent e bits 1-8 If 0<e<255, then value = (-1)s x 2e-127 x 1.m If e=0, s=0, m=0, then value = 0 If e=0, s=1, m=0, then value = -0 For a general discussion of fp arithmetic see http://www.ee.columbia.edu/~marios/matlab/Fall96Cleve.pdf 22 October 2013 Birkbeck College, U. London