CSCI206 - Computer Organization & Programming

Slides:



Advertisements
Similar presentations
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
Advertisements

Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved Floating-point Numbers.
Floating Point (FLP) Representation A Floating Point value: f = m*r**e Where: m – mantissa or fractional r – base or radix, usually r = 2 e - exponent.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
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.
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.
M68K Assembly Language Programming Bob Britton Chapter 12 IEEE Floating Point Notice: Chapter slides in this series originally provided by B.Britton. This.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
Floating Point Numbers
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
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…
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Simple Data Type Representation and conversion of numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Factional Values What is 0.75 in binary?. How could we represent fractions? In decimal: – As fractions : 1/5.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
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.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
CSPP58001 Floating Point Numbers. CSPP58001 Floating vs. fixed point Floating point refers to a binary decimal representation where there is not a fixed.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Floating Point in Binary 1.Place Value Chart:
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
IT11004: Data Representation and Organization Floating Point Representation.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Lecture 6: Floating Point Number Representation Information Representation: Floating Point Number Representation Lecture # 7.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Floating Point (FLP) Representation
FLOATING-POINT NUMBER REPRESENTATION
CSCI206 - Computer Organization & Programming
Floating Point. Binary Fractions.
Floating Point Numbers
Floating Point Representations
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Computer Science 210 Computer Organization
Introduction To Computer Science
Computer Architecture & Operations I
Floating Point Representations
CSCI206 - Computer Organization & Programming
Number Systems and Binary Arithmetic
Floating Point Math & Representation
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
Data Structures Mohammed Thajeel To the second year students
Topic 3d Representation of Real Numbers
Luddy Harrison CS433G Spring 2007
Number Representations
CSCI206 - Computer Organization & Programming
Computer Science 210 Computer Organization
CS 101 – Sept. 4 Number representation Integer Unsigned √ Signed √
Number Representation
Storing Integers and Fractions
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
IT11004: Data Representation and Organization
Numbers with fractions Could be done in pure binary
Computer Organization and Assembly Language
OBJECTIVES After reading this chapter, the reader should be able to :
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

CSCI206 - Computer Organization & Programming Introduction to Floating Point Numbers zyBook: 10.5

Real Numbers in Binary Recall the equation describing a positional number system:

Real Numbers in Binary Recall the equation describing a positional number system: This can be extended to real numbers: http://www.virtualnerd.com/pre-algebra/real-numbers-right-triangles/real-and-irrational/define-real-numbers/real-number-definition decimal point!

Examples base 10 0.1 in binary is = 0.5 (base 10)

Real Numbers in Binary Fractions of a power of 2 are easy Other values are represented using the sum of fractions with a power of 2 denominator

Real Numbers in Binary For example, 0.510 = 0.12 0.7510 = 0.510 + 0.2510 = 0.112 0.87510 = 0.7510 + 0.12510 = 0.1112 0.62510 = 0.510 + 0.12510 = 0.1012

Algorithm to Convert Decimal to Binary For decimal to binary integers we divided by 2 and record the remainder. For decimal to binary fraction numbers we multiply by 2 and record the integer part. Example: convert to binary.

binary digits beginning to the right of the decimal to binary binary digits beginning to the right of the decimal

binary digits beginning to the right of the decimal to binary binary digits beginning to the right of the decimal

binary digits beginning to the right of the decimal to binary binary digits beginning to the right of the decimal

binary digits beginning to the right of the decimal to binary binary digits beginning to the right of the decimal

binary digits beginning to the right of the decimal to binary binary digits beginning to the right of the decimal only work with fractional part!

fraction part is zero, stop! to binary = 0.00011 It appears magic, but the reason behind the algorithm is to find k, such that v * 2^k = 1.0, as v is expressed as b0*2^(-1)+b1*2^(-2) … fraction part is zero, stop!

Convert binary to decimal Convert 0.000112 to decimal 0.000112 == 2-4 + 2-5 == 1/16 + 1/32 == 3/32 == 0.0937510

Number Representation in Computing For a given range of integers, there is a corresponding range of (exact) binary representations Example: the range [0-15] corresponds to the 4-bit binary numbers 0000 through 1111.

Number Representation in Computing Within a range of real numbers, there is no way to encode all possible values. Example: the range [0.0 - 1.0] has an infinite number of points, so we would need an infinite number of bits to represent all of the possible values! As a result, in computing, real numbers are approximate. Activity 24, question 1 - 2

An Observation Many common base 10 real numbers generate an infinite number of binary digits

Fixed vs. Floating Point Approximations

Floating Point Representation Decimal notation Scientific notation 2 2×100 300 3×102 321.7 3.217×102 −53,000 −5.3×104 6,720,000,000 6.72×109 0.2 2×10−1 Floating Point Representation Where S is the sign bit M is a fixed point number (precision of numbers) E is a signed integer (range of numbers) S Exponent Mantissa or Fraction 32 or 64 bit word

IEEE 754 Standard (1985) S Exponent Mantissa One bit for Sign Single precision float (32 bits) 8 bit Exponent 23 bit Mantissa Double precision float (64 bits) 11 bit Exponent 52 bit Mantissa

IEEE 754 Standard (1985) S Exponent Mantissa Mantissa is normalized, meaning it is a fixed point number in the form 1.xxxxxx to save one bit, the 1. is implicit (not represented) Exponent is represented in biased form B = 127 for single B = 1023 for double