Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.

Slides:



Advertisements
Similar presentations
The Binary Numbering Systems
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.
Chapter 2: Data Representation
Principles of Computer Architecture Miles Murdocca and Vincent Heuring Chapter 2: Data Representation.
Chapter 1.7 Storing Fractions. Excess Notation, continued… In this notation, "m" indicates the total number of bits. For us (working with 8 bits), it.
Connecting with Computer Science, 2e
Representing Information as Bit Patterns
Assembly Language and Computer Architecture Using C++ and Java
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.

2-1 Computer Organization Part Fixed Point Numbers Using only two digits of precision for signed base 10 numbers, the range (interval between lowest.
Chapter 1 Data Storage. 2 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 12 Data.
Binary Number Systems.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Binary Representation and Computer Arithmetic
Chapter 5 Data representation.
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
The Binary Number System
Data Representation Number Systems.
Simple Data Type Representation and conversion of numbers
Lecture 5.
Computing Higher - Unit 1… Computer Systems 1 Higher Computing Unit 1 – Topic 1 Data Representation.
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Information Representation (Level ISA3) Floating point numbers.
Computer Arithmetic Nizamettin AYDIN
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 Math CPS120: Data Representation. Representing Data The computer knows the type of data stored in a particular location from the context in which.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
Chapter 1 Data Storage(3) Yonsei University 1 st Semester, 2015 Sanghyun Park.
IT253: Computer Organization
Computer Architecture
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer.
Data Representation and Computer Arithmetic
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,
9.4 FLOATING-POINT REPRESENTATION
©Brooks/Cole, 2003 Chapter 3 Number Representation.
CSC 221 Computer Organization and Assembly Language
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Representation, Number Systems and Base Conversions
Fractions in Binary.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Data Representation.
Lecture 6 Excess Notation. Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000 Excess 8 notation indicates that.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Department of Computer Science Georgia State University
Fundamentals of Computer Science
Backgrounder: Binary Math
Computer Science: An Overview Eleventh Edition
Introduction To Computer Science
Chapter 3 Data Storage.
CS1010 Programming Methodology
Data Structures Mohammed Thajeel To the second year students
Storing Negative Integers
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Chapter3 Fixed Point Representation
1.6) Storing Integer: 1.7) storing fraction:
Presentation transcript:

Lecture 5

Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric Values Representing Images Representing Images Sec 1.6 Storing Integers Two’s Complement Notation Two’s Complement Notation Excess Notation Excess Notation

Representing Text Each character (letter, punctuation, etc.) is assigned a unique bit pattern. Each character (letter, punctuation, etc.) is assigned a unique bit pattern. ASCII: Uses patterns of 7-bits to represent most symbols used in written English text ASCII: Uses patterns of 7-bits to represent most symbols used in written English text Unicode: Uses patterns of 16-bits to represent the major symbols used in languages world side Unicode: Uses patterns of 16-bits to represent the major symbols used in languages world side ISO standard: Uses patterns of 32-bits to represent most symbols used in languages world wide ISO standard: Uses patterns of 32-bits to represent most symbols used in languages world wide

Figure 1.12 The message “Hello.” in ASCII

Representing Numeric Values Binary notation: Uses bits to represent a number in base two Binary notation: Uses bits to represent a number in base two Limitations of computer representations of numeric values Limitations of computer representations of numeric values Overflow – occurs when a value is too big to be represented Overflow – occurs when a value is too big to be represented Truncation – occurs when a value cannot be represented accurately Truncation – occurs when a value cannot be represented accurately

Representing Images Images are stored using a variety of formats and compression techniques Images are stored using a variety of formats and compression techniques The simplest representation is a bitmap The simplest representation is a bitmap Bitmaps partition an image into a grid of picture elements, called pixels, and then convert each pixel into a bit pattern Bitmaps partition an image into a grid of picture elements, called pixels, and then convert each pixel into a bit pattern Resolution refers to the sharpness or clarity of an image bitmaps that are divided into smaller pixels will yield higher resolution images the left image is stored using 96 pixels per square inch, and the right image is stored using 48 pixels per square inch  the left image appears sharp, but has twice the storage requirements

Storing Integers Integers are categorized as: Integers are categorized as: Signed Integers Signed Integers Unsigned Integers Unsigned Integers Signed are those that include positive as well as negative numbers Signed are those that include positive as well as negative numbers While Unsigned are those that only represent positive numbers While Unsigned are those that only represent positive numbers The range for Signed Numbers is reduced to half The range for Signed Numbers is reduced to half

Signed Integers There are two ways to represent Signed Integers: Two’s complement notation: The most popular means of representing integer values Two’s complement notation: The most popular means of representing integer values Excess notation: Another means of representing integer values Excess notation: Another means of representing integer values Both can suffer from overflow errors. Both can suffer from overflow errors.

Representing Negative Numbers Can use “+” and “-”, as usual. Can use “+” and “-”, as usual. But requires extra symbols. How can we use bits instead? But requires extra symbols. How can we use bits instead? DecimalBinary

1-11 Figure 1.21 Two’s complement notation systems

Two’s complement Notation Invert all bits, then add 1. Invert all bits, then add 1. Decimal Binary 4-bit (1 bit sign + 3 bits magnitude) Decimal Binary 4-bit (1 bit sign + 3 bits magnitude)

Two’s complement – it just works! 0011 (3 decimal) (2 decimal) = (5 decimal ?) 1101 (-3 decimal) (-2 decimal) = (-5 decimal ?) 0011 (3 decimal) (-2 decimal) = (1 decimal ?)

Problems with binary arithmetic Fixed number of bits  can go out of range. Fixed number of bits  can go out of range (3 decimal) 0011 (3 decimal) (7 decimal) = 1010 (-6 decimal???) Overflow: When result can’t be represented within range of bits. Overflow: When result can’t be represented within range of bits. Overflow occurs when the value that we compute cannot fit into the number of bits we have allocated for the result. Overflow occurs when the value that we compute cannot fit into the number of bits we have allocated for the result. In addition, if operands have same sign and sum doesn’t. In addition, if operands have same sign and sum doesn’t.

Excess Notation Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000 Excess 8 notation indicates that the value for zero is the bit pattern for 8, that is 1000 The bit patterns are 4 bits long The bit patterns are 4 bits long Positive numbers are above it in order and negative numbers are below it in order. Positive numbers are above it in order and negative numbers are below it in order.

Figure 1.24 An excess eight conversion table

Excess Notation (continue) That is the zero point for Excess 128 notation is 128; the zero point for excess 64 notation is 64; and so forth. That is the zero point for Excess 128 notation is 128; the zero point for excess 64 notation is 64; and so forth. For example, let's say we want to determine the pattern for 15 in Excess 128 notation. For example, let's say we want to determine the pattern for 15 in Excess 128 notation. The decimal number would be , or 143. Therefore, the bit pattern would be The decimal number would be , or 143. Therefore, the bit pattern would be

Storing Fractions In contrast to storage of Integers the storage of fractions requires not only the representation of the magnitude by the radix point as well In contrast to storage of Integers the storage of fractions requires not only the representation of the magnitude by the radix point as well A popular way of doing this is based on scientific notation called Floating-Point Notation A popular way of doing this is based on scientific notation called Floating-Point Notation

Binary Fractions (revisited) We use a radix point in the same role as the decimal point in decimal notation. That is, the digits to the left of the radix point represent the integer part of the value. The digits to the right represent the fractional part of the value. We use a radix point in the same role as the decimal point in decimal notation. That is, the digits to the left of the radix point represent the integer part of the value. The digits to the right represent the fractional part of the value. _ _ _. _ _ _ _ _ _. _ _ _ Example: is 5 5/8 and is 5 11/ is 5 5/8 and is 5 11/ = 1/ = 1/ = 1/8

Short Cut (Bin --- Decimal) Binary-to-decimal for the part after the point Binary-to-decimal for the part after the point 1. Convert binary digits as though there were no point. 2. Divide result by 2 #bits – e.g., if 7 bits converted, then divide by 2 7 = 128. E.g.,.1101 E.g.,.1101 – 1101 = 13 – So,.1101 = 13  2 4 = 13/16 =.8125

1-21 Figure 1.26 Floating-point notation components

Look at Scientific Notation Real5 digits and an exponentFloating point * * * * * * ,555, * * 10 8 The last example shows us one of the problems with floating-point notation – truncation error. Part of the value being stored is lost because the mantissa field is not large enough. Let's look at some decimal numbers first, to get a feel for what needs to be done. First we need to know how many digits in the mantissa. Let's choose 5.

Floating Point Notation Now let's switch to binary. Although a common standard uses 64 bits for a floating-point number: 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa, we will use an abbreviated version. Let's use one byte: 1 bit for the sign, 3 bits for the exponent, and 4 bits for the mantissa. Now let's switch to binary. Although a common standard uses 64 bits for a floating-point number: 1 bit for the sign, 11 bits for the exponent, and 52 bits for the mantissa, we will use an abbreviated version. Let's use one byte: 1 bit for the sign, 3 bits for the exponent, and 4 bits for the mantissa.

The sign is easy enough 0 or 1. The sign is easy enough 0 or 1. The exponent has 3 bits and must be either + or -. We could use 2's complement, but excess notation is used instead! 3 bits means excess 4 notation. That leaves 4 bits for the mantissa. Why excess notation? It gives the best range of exponents and ease of wiring the circuitry. The exponent has 3 bits and must be either + or -. We could use 2's complement, but excess notation is used instead! 3 bits means excess 4 notation. That leaves 4 bits for the mantissa. Why excess notation? It gives the best range of exponents and ease of wiring the circuitry.

Excess 4 Notation – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = – 4 = 3

How to convert ?? Determine the sign bit Determine the sign bit Convert the whole number to binary Convert the whole number to binary Convert the fraction to binary Convert the fraction to binary Move the radix to the left of the most significant digit (left-most non-zero digit) Move the radix to the left of the most significant digit (left-most non-zero digit) Determine the exponent in excess 4 notation Determine the exponent in excess 4 notation

Example: To store 1 1/8 we express it in binary notation and obtain To store 1 1/8 we express it in binary notation and obtain Copy the bit patterns into the mantissa field from left to right. Copy the bit patterns into the mantissa field from left to right.

Example 1 Examples: Examples: +2 3/4 +2 3/4 This is positive so our sign bit is 0 This is positive so our sign bit is 0 2 is 10 2 is 10 3/4 is.11 3/4 is.11 This gives us Move the radix two places to the left:.1011 This gives us Move the radix two places to the left:.1011 So the exponent is +2: 110 in excess 4 So the exponent is +2: 110 in excess 4 Giving us: Giving us:

Example This is negative so our sign bit is 1 This is negative so our sign bit is 1 1 is 1 1 is is 3/16 giving us is 3/16 giving us.0011 This gives us : Because we have 4 bits we have to use 1.001: Move the radix one place to the left:.1001 This gives us : Because we have 4 bits we have to use 1.001: Move the radix one place to the left:.1001 So the exponent is +1: 101 in excess 4 So the exponent is +1: 101 in excess 4 Giving us: Giving us:

Example 3 What is in decimal? What is in decimal? Split it apart into its pieces: Split it apart into its pieces: The sign is 1 or negative The sign is 1 or negative The exponent is 011 or -1 The exponent is 011 or -1 The mantissa is Move the radix one place to the left: giving us 3/8 The mantissa is Move the radix one place to the left: giving us 3/8 Our number is -3/8 Our number is -3/8