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.

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

Lecture - 2 Number systems and computer data formats
2-1 Chapter 2 - Data Representation Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Chapter 2: Data Representation
Floating Point Numbers
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Floating Point Numbers
Floating Point Numbers. CMPE12cGabriel Hugh Elkaim 2 Floating Point Numbers Registers for real numbers usually contain 32 or 64 bits, allowing 2 32 or.
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.
2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
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…
The IEEE Format for storing float (single precision) data type Use the “enter” key to proceed through the show.
Lecture 8 Floating point format
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Binary Representation and Computer Arithmetic
Introduction to Computing Systems from bits & gates to C & beyond Chapter 2 Bits, Data Types & Operations Integer Representation Floating-point Representation.
Simple Data Type Representation and conversion of numbers
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
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.
Computer Architecture
Data Representation and Computer Arithmetic
COMPSCI 210 Semester Tutorial 1
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,
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
The Teacher CP4 Binary and all that… CP4 Revision.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
1 Lecture 2  Complement  Floating Point Number  Character Encoding.
CSC 221 Computer Organization and Assembly Language
The Teacher CP4 Binary and all that… CP4 Revision.
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Fractions in Binary.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Floating Point in Binary 1.Place Value Chart:
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
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.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
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 Numbers
Floating Point Representations
Fundamentals of Computer Science
Computer Science 210 Computer Organization
Introduction To Computer Science
Floating Point Number system corresponding to the decimal notation
Topic 3d Representation of Real Numbers
Chapter 2 Bits, Data Types & Operations Integer Representation
Number Representations
Computer Science 210 Computer Organization
Cosc 2P12 Week 2.
Floating Point Numbers
COMS 161 Introduction to Computing
Topic 3d Representation of Real Numbers
Numbers with fractions Could be done in pure binary
Cosc 2P12 Week 2.
Number Representations
Presentation transcript:

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 language When a key is pressed on the keyboard a unique representation of the key is transmitted to the computer ASCII 1 assigns unique representations to 128 characters (see page 102 of the text) 1 American Standard for Computer Information Interchange

While the characters are not numbers, their unique representations are 7-bit unsigned binary representation The representations allow programmers to easily compare characters using equality or relational operators (e.g., >, <= ) An operation that can take advantage of how the ASCII representation are arranged is sorting.

Example 10.1 (char integer) moveint 0 getch procch:bgt ch,’9’,notadigit blt ch,’0’,notadigit subch,ch,’0’ mul int,int,10 add int,int,ch getch bprocch notadigit: Check that the character read is a digit Convert into decimal

Floating Point Representation The IEEE Floating Point Standard (FPS) is a widely used floating point representation from among the many alternative formats The representation for floating point numbers are broken into two parts:  mantissa (variant of a scaled, sign magnitude integer)  exponent (8-bit, biased-127 integer) 1 +

A number N represented in floating point is determined by the mantissa m and an exponent e N = (-1) s * m * 2 e If the sign of the mantissa is negative, s = 1 ; if the sign of the mantissa is positive, s = 0. The mantissa is normalized, i.e., 1  m < 2 In the FPS format, the precision is specified as 24 bits thus m = 1.f 22 f 21 …f 1 f 0 1 +

Conversion to Floating Point Representation 1.Break the decimal number into two parts: an integer and a fraction 2.Convert the integer into binary and place it to the left of the binary point 3.Convert the fraction into binary and place it to the right of the binary point 4.Write it in scientific notation and normalize

Example 10.2 Convert to floating point representation 1. Convert 22 to binary = Convert.625 to binary 2*.625= *.25 = *.5= Thus = In scientific notation: *2 0 Normalized form: * =.101 2

IEEE FPS Representation Given the floating point representation N = (-1) s * m * 2 e where m = 1.f 22 f 21 …f 1 f 0 we can convert it to the IEEE FPS format using the relations: F = (m-1)*2 n E =e S =s SEF

Single-Precision Floating Point The IEEE FPS single precision format has 32 bits distributed as 0  E  255, thus the true exponent e is restricted so that -126  e  127 SEF F = fractional part of the significand

Zero and the Hidden bit In IEEE FPS, zero is represented by setting E = F = 0 regardless of the sign bit, thus there are two representations for zero: +0 and  by S=0, E=255, F=0 -  by S=1, E=255, F=0 NaN or Not-a-Number by E=255, F  0 (may result from 0 divide by 0) The leading 1 in the fraction is not represented. It is the hidden bit.

Converting to IEEE FPS 1.Convert into a normalized floating point representation 2.Bias the exponent. The result will be E. 3.Put the values into the correct field. Note that only the fractional part of the significand is placed into F.

Example 10.3 Convert to IEEE FPS format (single precision) 1. In scientific notation: *2 0 Normalized form: * Bias the exponent: = = Place into the correct fields. S = 0 E = F = SE F

Example 10.4 Convert to IEEE FPS format (single- precision) = * Normalized form: * Bias the exponent: = = Place into the correct fields. S = 0 E = F = SE F

Example 10.5 Convert to IEEE FPS format (single precision) 2*.7 = *.4 = *.8 = *.6 = *.2 = *.4 = *.8 = *.6 = *.2 = = Note: this is in single-precision floating point representation format but not FPS format

1. In scientific notation: * 10 0 Normalized form: * Bias the exponent: = = Place into the correct fields. S = 1 E = F = SE F