Computer Science 210 Computer Organization

Slides:



Advertisements
Similar presentations
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Advertisements

2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
Booth’s Algorithm.
Floating Point Numbers
Computer Science 210 Computer Organization Floating Point Representation.
Lecture 8 Floating point format
Binary Representation and Computer Arithmetic
Simple Data Type Representation and conversion of numbers
Ch. 2 Floating Point Numbers
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Data Representation - Part II. Characters A variable may not be a non-numerical type Character is the most common non- numerical type in a programming.
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
ITEC 1011 Introduction to Information Technologies 4. Floating Point Numbers Chapt. 5.
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 Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Numbers in Computers.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
R EPRESENTATION OF REAL NUMBER Presented by: Pawan yadav Puneet vinayak.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point (FLP) Representation
Chapter 9 Computer Arithmetic
FLOATING-POINT NUMBER REPRESENTATION
William Stallings Computer Organization and Architecture 8th Edition
CSCI206 - Computer Organization & Programming
Floating Point Numbers
Lecture 6. Fixed and Floating Point Numbers
Department of Computer Science Georgia State University
Computer Science 210 Computer Organization
Computer Science 210 Computer Organization
A brief comparison of integer and double representation
Introduction To Computer Science
Computer Architecture & Operations I
Number Systems and Binary Arithmetic
Data Representation Binary Numbers Binary Addition
Floating Point Math & Representation
Lecture 9: Floating Point
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
IEEE floating point format
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
William Stallings Computer Organization and Architecture 7th Edition
Topic 3d Representation of Real Numbers
Luddy Harrison CS433G Spring 2007
Chapter 2 Bits, Data Types & Operations Integer Representation
CSCI206 - Computer Organization & Programming
Number Representations
Data Representation Data Types Complements Fixed Point Representation
Computer Science 210 Computer Organization
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Floating Point Numbers
Recent from Dr. Dan Lo regarding 12/11/17 Dept Exam
Topic 3d Representation of Real Numbers
CS 286 Computer Architecture & Organization
Numbers with fractions Could be done in pure binary
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Computer Science 210 Computer Organization Floating Point Representation

Why “Floating Point” ? For many applications (e.g., banking) it’s okay to have a fixed position for the decimal point: $2.99, $101.23, etc., where decimal point is always to places from the right. In applications where we need more precision (e.g., scientific computing), we need the decimal point to “float” around in the number: 1234.56, 123.456, 12.3456, etc.

Real Numbers Format 1: <whole part>.<fractional part> Examples: 0.25, 3.1415 … Format 2 (normalized form): <digit>.<fractional part> × <exponent> Example: 2.5 × 10-1 In mathematics, infinite range and infinite precision (“uncountably infinite”)

math.pi Looks like about 48 places of precision (in base10) >>> import math >>> math.pi 3.141592653589793 >>> print(math.pi) 3.14159265359 >>> print("%.50f" % math.pi) 3.14159265358979311599796346854418516159057617187500 Looks like about 48 places of precision (in base10)

IEEE Standard Single precision: 32 bits Double precision: 64 bits 2.5 × 10-1 Reserve some bits for the significand (the digits to the left of ×) and some for the exponent (the stuff to the right of ×) Double precision uses 52 bits for the significand, 11 bits for the exponent, and one sign bit Approximate double precision range is 10-308 to 10308

IEEE Single Precision Format 32 bits Roughly (-1)S x F x 2E F is related to the significand E is related to the exponent Rough range Small fractions 2 x 10-38 Large fractions 2 x 1038 S Exponent Significand 1 8 23

Fractions in Binary In general, 2-N = 1/2N 0.12 = 1 × 2-1 = 1 × ½ = 0.510 0.012 = 1 × 2-2 = 1 × ¼ = 0.2510 0.112 = 1 × ½ + 1 × ¼ = 0.7510

Decimal to Binary Conversion (Whole Numbers) While N > 0 do Set N to N/2 (whole part) Record the remainder (1 or 0) Set A to remainders in reverse order

Decimal to Binary - Example Example: Convert 32410 to binary N Rem N Rem 324 162 0 5 0 81 0 2 1 40 1 1 0 20 0 0 1 10 0 32410 = 1010001002

Decimal to Binary - Fractions While fractional part > 0 do Set N to N*2 (whole part) Record the whole number part (1 or 0) Set N to fraction part Set bits to sequence of whole number parts (in order obtained)

Decimal fraction to binary - Example Example: Convert .6562510 to binary N Whole Part .65625 1.31250 1 0.6250 0 1.250 1 0.50 0 1.0 1 .6562510 = .101012

Decimal fraction to binary - Example Example: Convert .4510 to binary N Whole Part .45 0.9 0 1.8 1 1.6 1 1.2 1 0.4 0 0.8 0 1.6 1 .4510 = .011100110011…2

Round-Off Errors Caused by conversion of decimal fractions to binary >>> 0.1 0.1 >>> print("%.48f" % 0.1) 0.100000000000000005551115123125782702118158340454 >>> print("%.48f" % 0.25) 0.250000000000000000000000000000000000000000000000 >>> print("%.48f" % 0.3) 0.299999999999999988897769753748434595763683319092 Caused by conversion of decimal fractions to binary

Scientific Notation - Decimal Number Normalized Scientific 0.000000001 1.0 x 10-9 5,326,043,000 5.326043 x 109

Floating Point IEEE 754 Single Precision Standard (32 bits) Roughly (-1)S x F x 2E F is related to significand E is related to exponent Rough range Small fractions 2 x 10-38 Large fractions 2 x 1038 S Exponent Significand 1 8 23

Floating Point – Exponent Field This comes before significand for sorting purposes With 8 bit exponent range would be –128 to 127 Note: -1 would be 11111111 and with simple sorting would appear largest. For this reason, we take the exponent, add 127 and represent this as unsigned. This is called bias 127. Then exponent field 11111111 (255) would represent 255 - 127 = 128. Also 00000000 (0) would represent 0 - 127 = -127. Range of exponents is -127 to 128

Floating Point – Significand Normalized form: 1.1011… x 2E Hidden bit trick: Since the bit to left of binary point is always 1, why store it? We don’t. Number = (-1)S x (1+Significand) x 2E-127

Floating Point Example: Convert 312.875 to IEEE Step 1. Convert to binary: 100111000.111 Step 2. Normalize: 1.00111000111 x 28 Step 3. Compute biased exponent in binary: 8 + 127 = 135  10000111 Step 4. Write the floating point representation: 0 10000111 00111000111000000000000 or 439C7000 in hexadecimal

Floating Point Example: Convert IEEE 11000000101000… to decimal Step 1. Sign bit is 1; so number is negative Step 2. Exponent field is 10000001 or 129; so actual exponent is 2 Step 3. Significand is 010000…; so 1 + Significand is 1.0100… Step 4. Number = (-1)S x (1+Significand) x 2E-127 = (-1)1 x (1.010) x 22 = -101 = -5

For Next Time Section 2.6: Boolean Algebra Sections 3.1, 3.2: Transistors and Logic Gates