Number Representations

Slides:



Advertisements
Similar presentations
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.
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
COMP3221: Microprocessors and Embedded Systems Lecture 14: Floating Point Numbers Lecturer: Hui Wu Session 2, 2004.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
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.
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Science 210 Computer Organization Floating Point Representation.
School of Computer Science G51CSA 1 Computer Arithmetic.
Simple Data Type Representation and conversion of numbers
Ch. 2 Floating Point Numbers
Number Systems II Prepared by Dr P Marais (Modified by D Burford)
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
9.4 FLOATING-POINT REPRESENTATION
Floating Point Representations CDA 3101 Discussion Session 02.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
CSC 4250 Computer Architectures September 5, 2006 Appendix H. Computer Arithmetic.
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Data Representation: Floating Point for Real Numbers Computer Organization and Assembly Language: Module 11.
Numbers in Computers.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
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.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Floating Point Numbers
Floating Point Representations
Lecture 6. Fixed and Floating Point Numbers
Computer Science 210 Computer Organization
Binary Numbers The arithmetic used by computers differs in some ways from that used by people. Computers perform operations on numbers with finite and.
Number Representation
Computer Architecture & Operations I
2.4. Floating Point Numbers
Floating Point Representations
CSCI206 - Computer Organization & Programming
Integer Division.
Lecture 9: Floating Point
Floating Point Numbers: x 10-18
Floating Point Number system corresponding to the decimal notation
CS/COE0447 Computer Organization & Assembly Language
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
CSCI206 - Computer Organization & Programming
Data Representation Data Types Complements Fixed Point Representation
Floating Point Representation
CSCI206 - Computer Organization & Programming
CS 61C: Great Ideas in Computer Architecture Floating Point Arithmetic
Computer Science 210 Computer Organization
How to represent real numbers
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Floating Point Numbers
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
Topic 3d Representation of Real Numbers
Floating Point Numbers
CS 286 Computer Architecture & Organization
Numbers with fractions Could be done in pure binary
Computer Organization and Assembly Language
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Number Representations

Numbers with Fractions So, done with negative numbers. Done with signed and unsigned integers. How about numbers with fractions? How to represent, say, 5.75ten in binary forms?

Numbers with Fractions In general, to represent a real number in binary, you first find the binary representation of the integer part, then find the binary representation of the fraction part, then put a dot in between.

Numbers with fractions The integer part is 5ten which is 101two. How did you get it?

Numbers with Fractions The fraction is 0.75. Note that it is 2-1 + 2-2 = 0.5 + 0.25, so 5.75ten = 101.11two

How to get the fraction In general, what you do is kind of the reverse of getting the binary representation for the integer: divide the fraction first by 0.5 (2-1), take the quotient as the first bit of the binary fraction, then divide the remainder by 0.25 (2-2), take the quotient as the second bit of the binary fraction, then divide the remainder by 0.125 (2-3),

How to get the fraction Take 0.1 as an example. 0.1/0.5=0*0.5+0.1 –> bit 1 is 0. 0.1/0.25 = 0*0.25+0.1 –> bit 2 is 0. 0.1/0.125 = 0*0.125+0.1 –> bit 3 is 0. 0.1/0.0625 = 1*0.0625+0.0375 –> bit 4 is 1. 0.0375/0.03125 = 1*0.03125+0.00625 –> bit 5 is 1. And so on, until the you have used all the bits that hardware permits

Floating Point Numbers 11/19/2018 Floating Point Numbers Recall scientific notation for decimal numbers A number is represented by a significand (or mantissa) and an integer exponent F * 10E Where F is the significand, and E the exponent Example: 3.1415926 * 102 Normalized if F is a single digit number 11/19/2018 CDA3100 CDA3100

Floating Points in Binary 11/19/2018 Floating Points in Binary Normalized binary scientific notation For a fixed number of bits, we need to decide How many bits for the significand (or fraction) How many bits for the exponent There is a trade-off between precision and range More bits for significand increases precision while more bits for exponent increases the range 11/19/2018 CDA3100 CDA3100

IEEE 754 Floating Point Standard 11/19/2018 IEEE 754 Floating Point Standard Single precision Represented by 32 bits Since the leading 1 bit in the significand in normalized binary numbers is always 1, it is not represented explicitly 11/19/2018 CDA3100 CDA3100

11/19/2018 Exponent If we represent exponents using two’s complement, then it would not be intuitive as small numbers appear to be larger 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 11/19/2018 CDA3100 CDA3100

11/19/2018 Biased Notation The most negative exponent will be represented as 00…00 and the most positive as 111…11 That is, we need to subtract the bias from the corresponding unassigned value The value of an IEEE 754 single precision is 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 s exponent fraction 1 bit 8 bits 23 bits 11/19/2018 CDA3100 CDA3100

Example 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75ten 11/19/2018 Example 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75ten The normalized binary number will be 1.011122 = 1.01112(129-127) So the exponent is 129ten = 10000001 As a hexadecimal number, the representation is 0x40B80000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 11/19/2018 CDA3100 CDA3100

IEEE 754 Double Precision It uses 64 bits (two 32-bit words) 11/19/2018 IEEE 754 Double Precision It uses 64 bits (two 32-bit words) 1 bit for the sign 11 bits for the exponent 52 bits for the fraction 1023 as the bias 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 s Exponent fraction 1 bit 11 bits 20 bits Fraction (continued) 32 bits 11/19/2018 CDA3100 CDA3100

Example (Double Precision) 11/19/2018 Example (Double Precision) 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 The normalized binary number will be 1.011122 = 1.01112(1025-1023) So the exponent is 1025ten = 10000000001two As a hexadecimal number, the representation is 0x4017 0000 0000 0000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 11/19/2018 CDA3100 CDA3100

floating-point number 11/19/2018 Special Cases Single precision Double precision Object represented Exponent Fraction nonzero denormalized number 1-254 anything 1-2046 floating-point number 255 2047  infinity NaN (Not a number) Denormalized If the exponent is all 0s, but the fraction is non-zero (else it would be interpreted as zero), then the value is a denormalized number, which does not have an assumed leading 1 before the binary point. Thus, this represents a number (-1)s × 0.f × 2-126, where s is the sign bit and f is the fraction. For double precision, denormalized numbers are of the form (-1)s × 0.f × 2-1022. From this you can interpret zero as a special type of denormalized number. 11/19/2018 CDA3100 CDA3100

Floating Point Numbers How many different numbers can the single precision format represent? What is the largest number it can represent?

Ranges for IEEE 754 Single Precision 11/19/2018 Ranges for IEEE 754 Single Precision Largest positive number Smallest positive number (floating point) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 11/19/2018 CDA3100 CDA3100

Ranges for IEEE 754 Single Precision 11/19/2018 Ranges for IEEE 754 Single Precision Largest positive number Smallest positive number (floating point) 11/19/2018 CDA3100 CDA3100

Ranges for IEEE 754 Double Precision 11/19/2018 Ranges for IEEE 754 Double Precision Largest positive number Smallest positive number (Floating-point number) 11/19/2018 CDA3100 CDA3100

Comments on Overflow and Underflow 11/19/2018 Comments on Overflow and Underflow Overflow (and underflow also for floating numbers) happens when a number is outside the range of a particular representation For example, by using 8-bit two’s complement representation, we can only represent a number between - 128 and 127 If a number is smaller than -128, it will cause overflow If a number is larger than 127, it will cause overflow also Note that arithmetic operations can result in overflow 11/19/2018 CDA3100 CDA3100