Floating point numbers. Computable reals computable numbers may be described briefly as the real numbers whose expressions as a decimal are calculable.

Slides:



Advertisements
Similar presentations
© Vinny Cahill 1 Writing a Program in Java. © Vinny Cahill 2 The Hello World Program l Want to write a program to print a message on the screen.
Advertisements

Binary Values and Number Systems
2009 Spring Errors & Source of Errors SpringBIL108E Errors in Computing Several causes for malfunction in computer systems. –Hardware fails –Critical.
A-Level Computing#BristolMet Session Objectives#9 express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal; describe and use two’s.
HEXADECIMAL NUMBERS Code
CIS 020 Assembly Programming Chapter 02 - Numbering Systems & Data Representation © John Urrutia 2012, All Rights Reserved.5/27/20121.
PZ04A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ04A - Scalar and composite data Programming Language.
Data Representation. CMPE12cGabriel Hugh Elkaim 2 Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we.
Floating Point Numbers
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.
Floating Point Numbers.  Floating point numbers are real numbers.  In Java, this just means any numbers that aren’t integers (whole numbers)  For example…
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Memory Terminology & Data Representation CSCI 1060 Fall 2006.
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 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
IT253: Computer Organization
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 1. Data Representation Data Representation – Why do we use binary? simplicity,
Binary Arithmetic & Data representation
Data Representation and Computer Arithmetic
Information and Programs. Foundations of Computing Information –Binary numbers –Integers and Floating Point –Booleans (True, False) –Characters –Variables.
Copyright © 2002 W. A. Tucker1 Chapter 7 Lecture Notes Bill Tucker Austin Community College COSC 1315.
COMPSCI 210 Semester Tutorial 1
Why does it matter how data is stored on a computer? Example: Perform each of the following calculations in your head. a = 4/3 b = a – 1 c = 3*b e = 1.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Data Representation in Computer Systems
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
The Teacher CP4 Binary and all that… CP4 Revision.
CSC 221 Computer Organization and Assembly Language
The Teacher CP4 Binary and all that… CP4 Revision.
COMP201 Computer Systems Floating Point Numbers. Floating Point Numbers  Representations considered so far have a limited range dependent on the number.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Data Representation, Number Systems and Base Conversions
Fractions in Binary.
Data as the computer sees it 1.  Number systems Number systems  Data storage Data storage  Glossary Glossary 2.
Codes Octal Power Hexadecimal ASCII BCD Code
1 Information Representation in Computer Lecture Nine.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
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.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
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.
Binary numbers. Primary memory Memory = where programs and data are stored – Unit = bit “BIT” is a contraction for what two words? Either a 1 or a 0 (because.
1 Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Answer CHAPTER FOUR.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Nat 4/5 Computing Science Data Representation Lesson 3: Storing Text
Number Systems and Binary Arithmetic
Data Representation Binary Numbers Binary Addition
Chapter 6: Data Types Lectures # 10.
Floating Point Numbers: x 10-18
EPSII 59:006 Spring 2004.
A Level Computing Component 2
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
What to bring: iCard, pens/pencils (They provide the scratch paper)
Topic 3d Representation of Real Numbers
Data Representation Conversion 05/12/2018.
Storing Negative Integers
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
COMS 161 Introduction to Computing
Chapter 3 - Binary Numbering System
ECE 120 Midterm 1 HKN Review Session.
Presentation transcript:

Floating point numbers

Computable reals computable numbers may be described briefly as the real numbers whose expressions as a decimal are calculable by finite means.( A. M. Turing, On Computable Numbers with an Application to the Entschiedungsproblem, Proc. London Mathematical Soc., Ser. 2, Vol 42, pages , )

Look first at decimal reals A real number may be approximated by a decimal expansion with a determinate decimal point. As more digits are added to the decimal expansion the precision rises. Any effective calculation is always finite – if it were not then the calculation would go on for ever. There is thus a limit to the precision that the reals can be represented as.

Transcendental numbers In principle, transcendental numbers such as Pi or root 2 have no finite representation We are always dealing with approximations to them. We can still treat Pi as a real rather than a rational because there is always an algorithmic step by which we can add another digit to its expansion.

First solution Store the numbers in memory just as they are printed as a string of characters Would be stored as 6 bytes as shown below Note that decimal numbers are in the range 30H to 39H as ascii codes E3735 Full stop char Char for 3

Implications The number strings can be of variable length. This allows arbitrary precision. This representation is used in systems like Mathematica which requires very high accuracy.

Example with Mathematica 5! Out[1]=120 In[2]:=10! Out[2]= In[3]:=50! Out[3]=

Decimal byte arithmetic 9+ 8= 17 decimal 39H+38H=71H hexadecimal ascii 57+56=113 decimal ascii Adjust by taking 30H =48 away -> 41H =65 If greater than 9= 39H =57 take away 10= 0AH and carry 1 Thus 41H-0Ah = 65-10=55= 37H so the answer would be 31H,37H = 17

Representing variables Variables are represented as pointers to character strings in this system A= A E3735

Advantages Arbitrarily precise Needs no special hardware Disadvantages Slow Needs complex memory management

Binary Coded Decimal (BCD) or Calculator style floating point Note that can be represented as x 10 2 Store this 2 digits to a byte to fixed precision as follows bits overall Each digit uses 4 bits exponentmantissa

Normalise Convert N to format with one digit in front of the decimal point as follows: 1.If N>10 then Whilst N>10 divide by 10 and add 1 to the exponent 2.Else whilst N<1 multiply by 10 and decrement the exponent

Add floating point 1.Denormalise smaller number so that exponents equal 2.Perform addition 3.Renormalise Eg = E E E E E03

Note loss of accuracy Compare Octave which uses floating point numbers with Mathematica which uses full precision arithmetic Octave floating point gives only 5 figure accuracy Octave fact(5) ans = 120 fact(10) ans = fact(50) ans = e+64 Mathematica 5! Out[1]=120 10! Out[2]= ! Out[3]=

Loss of precison continued When there is a big difference between the numbers the addition is lost with floating point Octave ans = D+08 Mathematica In[1]:= Out[1]=

IEEE floating point numbers Institution of Electrical and Electronic Engineers

Single Precision EF

Definition N=-1 s x 1.F x 2 E-128 Example In fixed point binary = = x 2 1 In IEEE format this is s=0 E=129, F=10100… thus in IEEE it is S E F 0| | Delete this bit

Example = -3/8 In fixed point binary = =-1 1 x 1.1 x 2 -2 In IEEE format this is s=1 E=126, F=1000 … thus in IEEE it is S E F 1| |

Range IEEE * 10 –38 to * IEEE * 10 –308 to * bit 3.37 * 10 –4932 to *