# 3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

Size: px
Start display at page:

## Transcription

1 3 Data Storage 3.1 Foundations of Computer Science Cengage Learning

2 Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how different data is stored inside a computer. Describe how integers are stored in a computer. Describe how reals are stored in a computer. Describe how text is stored in a computer using one of the various encoding systems. Describe how audio is stored in a computer using sampling, quantization and encoding. Describe how images are stored in a computer using raster and vector graphics schemes. Describe how video is stored in a computer as a representation of images changing in time. 3.2

3 3-1 INTRODUCTION Different forms including numbers, text, audio, image and video (Figure 3.1). i Figure 3.1 Different types of data The computer industry uses the term multimedia to define information that contains numbers, text, images, audio and video. 3.3

4 Data inside the computer All data types are transformed into a uniform representation when they are stored in a computer and transformed back to their original form when retrieved. This universal representation is called a bit pattern. Figure 3.2 A bit pattern 3.4

5 3.5 Figure 3.3 Storage of different data types

6 Data compression To occupy less memory space, data is normally compressed before being stored in the computer. Data compression is a very broad and involved subject, so we have dedicated the whole of Chapter 15 to the subject. i Data compression is discussed in Chapter

7 Error detection and correction Another issue related to data is the detection and correction of errors during transmission or storage. We discuss this issue briefly in Appendix H. i Error detection and correction is discussed in Appendix H. 3.7

8 3-2 STORING NUMBERS A number is changed to the binary system before being stored in the computer memory, as described in Chapter 2. However, there are still two issues that need to be handled: 1. How to store the sign of the number. 2. How to show the decimal point. 3.8

9 STORING NUMBERS 8 = P.40

10 Storing integers Integers are whole numbers (numbers without a fractional part). For example, 134 and 125 are integers, whereas and are not. An integer can be thought of as a number in which the position of the decimal point is fixed: the decimal point is to the right of the least significant (rightmost) bit. (most right) 3.10

11 Figure 3.4 Fixed point representation of integers i An integer is normally stored in memory using fixed-point representation. 3.11

12 Unsigned representation An unsigned integer is an integer that can never be negative and can take only 0 or positive values. Its range is between 0 and positive infinity. An input device stores an unsigned integer using the following steps: 1. The integer is changed to binary. 2. If the number of bits is less than n, 0s are added to the left. 3.12

13 Example 3.1 Store 7 in an 8-bit memory location using unsigned representation. Solution First change the integer to binary, (111) 2. Add five 0s to make a total of eight bits, ( ) 2. The integer is stored in the memory location. Note that the subscript 2 is used to emphasize that the integer is binary, but the subscript is not stored in the computer. 3.13

14 Example 3.2 Store 258 in a 16-bit memory location. Solution First change the integer to binary ( ) 2. Add seven 0s to make a total of sixteen bits, ( ) 2. The integer is stored in the memory location. 3.14

15 Example 3.3 What is returned from an output device when it retrieves the bit string stored in memory as an unsigned integer? Solution Using the procedure shown in Chapter 2, the binary integer is converted to the unsigned integer

16 Figure 3.5 shows what happens if we try to store an integer that is larger than = 15 in a memory location that can only hold four bits Figure 3.5 Overflow in unsigned integers

17 Sign-and-magnitude representation In this method, the available range for unsigned integers (0 to 2 n 1) is divided into two equal sub-ranges. The first half represents positive integers, the second half, negative integers. i Figure 3.6 Sign-and-magnitude representation The leftmost bit defines the sign of the integer. If it is 0, the integer is positive. If it is 1, the integer is negative. 3.17

18 Example 3.4 Store +28 in an 8-bit memory location using sign-and-magnitude representation. Solution The integer is changed to 7-bit binary. The leftmost bit is set to 0. The 8-bit number is stored. 3.18

19 Example 3.5 Store 28 in an 8-bit memory location using sign-and-magnitude representation. Solution The integer is changed to 7-bit binary. The leftmost bit is set to 1. The 8-bit number is stored. 3.19

20 Example 3.6 Retrieve the integer that is stored as in sign-andmagnitude representation. Solution Since the leftmost bit is 0, the sign is positive. The rest of the bits ( ) are changed to decimal as 77. After adding the sign, the integer is

21 Example 3.7 Retrieve the integer that is stored as in sign-andmagnitude representation. Solution Since the leftmost bit is 1, the sign is negative. The rest of the bits ( ) are changed to decimal as 33. After adding the sign, the integer is

22 Figure 3.7 shows both positive and negative overflow when storing an integer in sign-and-magnitude representation using a 4-bit memory location Figure 3.7 Overflow in sign-and-magnitude representation

23 Sign-and-magnitude Problem 5 + (-5) = = ??? Sign-and-magnitude representation cannot approach binary operation. 3.23

24 Two s complement representation Almost all computers use two s complement representation to store a signed integer in an n-bit memory location. The available range for an unsigned integer of (0 to 2 n 1 ) is divided into two equal sub-ranges. The first sub-range is used to represent nonnegative integers, the second half to represent negative integers. The bit patterns are then assigned to negative and nonnegative (zero and positive) integers as shown in Figure

25 Figure 3.8 Two s complement representation i Figure 3.6 Sign-and-magnitude representation The leftmost bit defines the sign of the integer. If it is 0, the integer is positive. If it is 1, the integer is negative. 3.25

26 One s Complementing The first is called one s complementing or taking the one s complement of an integer. The operation can be applied to any integer, positive or negative. This operation simply reverses (flips) each bit. A 0-bit is changed to a 1-bit, a 1-bit is changed to a 0-bit. Example 3.8 The following shows how we take the one s complement of the integer

27 Example 3.9 The following shows that we get the original integer if we apply the one s complement operations twice. 3.27

28 Two s Complementing The second operation is called two s complementing or taking the two s complement of an integer in binary. This operation is done in two steps. First, we copy bits from the right until a 1 is copied; then, we flip the rest of the bits. Example 3.10 The following shows how we take the two s complement of the integer

29 Example 3.11 The following shows that we always get the original integer if we apply the two s complement operation twice. i An alternative way to take the two s complement of an integer is to first take the one s complement and then add 1 to the result. 3.29

30 Example 3.12 Store the integer 28 in an 8-bit memory location using two s complement representation. Solution The integer is positive (no sign means positive), so after decimal to binary transformation no more action is needed. Note that five extra 0s are added to the left of the integer to make it eight bits. 3.30

31 Example 3.13 Store 28 in an 8-bit memory location using two s complement representation. Solution The integer is negative, so after changing to binary, the computer applies the two s complement operation on the integer. 3.31

32 Example 3.14 Retrieve the integer that is stored as in memory in two s complement format. Solution The leftmost bit is 0, so the sign is positive. The integer is changed to decimal and the sign is added. 3.32

33 Example 3.15 Retrieve the integer that is stored as in memory using two s complement format. Solution The leftmost bit is 1, so the integer is negative. The integer needs to be two s complemented before changing to decimal. 3.33

34 i There is only one zero in two s complement notation Figure 3.9 Overflow in two s complement representation

35 Comparison 3.35

36 Storing reals A real is a number with an integral part and a fractional part. For example, 23.7 is a real number the integral part is 27 and the fractional part is 7/10. Although a fixed-point representation can be used to represent a real number, the result may not be accurate or it may not have the required precision. i Real numbers with very large integral parts or very small fractional parts should not be stored in fixedpoint representation. 3.36

37 Example 3.16 In the decimal system, assume that we use a fixed-point representation with two digits at the right of the decimal point and fourteen digits at the left of the decimal point, for a total of sixteen digits. The precision of a real number in this system is lost if we try to represent a decimal number such as : the system stores the number as Example 3.17 In the decimal system, assume that we use a fixed-point representation with six digits to the right of the decimal point and ten digits for the left of the decimal point, for a total of sixteen digits. The accuracy of a real number in this system is lost if we try to represent a decimal number such as The system stores the number as : the integral part is much smaller than it should be.

38 Floating-point representation The solution for maintaining accuracy or precision is to use floating-point representation. Figure 3.9 The three parts of a real number in floating-point representation i A floating point representation of a number is made up of three parts: a sign, a shifter and a fixed-point number. 3.38

39 Example 3.18 The following shows the decimal number 7,452,000,000,000,000,000, in scientific notation (floating-point representation). The three sections are the sign (+), the shifter (21) and the fixedpoint part (7.425). Note that the shifter is the exponent. 3.39

40 Example 3.19 Show the number in scientific notation (floating-point representation). Solution We use the same approach as in the previous example we move the decimal point after the digit 2, as shown below: The three sections are the sign ( ), the shifter ( 14) and the fixed-point part (2.32). Note that the shifter is the exponent. 3.40

41 Example 3.20 Show the number ( ) 2 in floating-point representation. Solution We use the same idea, keeping only one digit to the left of the decimal point. 3.41

42 Example 3.21 Show the number ( ) 2 in floating-point representation. Solution We use the same idea, keeping only one digit to the left of the decimal point. 3.42

43 Normalization To make the fixed part of the representation uniform, both the scientific method (for the decimal system) and the floating-point method (for the binary system) use only one non-zero digit on the left of the decimal point. This is called normalization. In the decimal system this digit can be 1 to 9, while in the binary system it can only be 1. In the following, d is a non-zero digit, x is a digit, and y is either 0 or

44 i Note that the point and the bit 1 to the left of the fixed-point section are not stored they are implicit. i The mantissa is a fractional part that, together with the sign, is treated like an integer stored in sign-andmagnitude representation. 3.44

45 Excess System The exponent, the power ( 次方 ) that shows how many bits the decimal point should be moved to the left or right, is a signed number. Although this could have been stored using two s complement representation, a new representation, called the Excess system, is used instead. In the Excess system, both positive and negative integers are stored as unsigned integers. A positive integer (called a bias) is added to each number to shift them uniformly to the non-negative side. The value of this bias is 2 m 1 1, where m is the size of the memory location to store the exponent. 3.45

46 Example 3.22 We can express sixteen integers in a number system with 4-bit allocation. By adding seven units to each integer in this range, we can uniformly translate all integers to the right and make all of them positive without changing the relative position of the integers with respect to each other, as shown in the figure. The new system is referred to as Excess-7, or biased representation with biasing value of Figure 3.11 Shifting in Excess representation

47 IEEE Standard Figure 3.12 IEEE standards for floating-point representation 3.47

48 IEEE Specifications 3.48

49 Example 3.23 Show the Excess_127 (single precision) representation of the decimal number Solution a. The sign is positive, so S = 0. b. Decimal to binary transformation: 5.75 = (101.11) 2. c. Normalization: (101.11) 2 = (1.0111) d. E = = 129 = ( ) 2, M = We need to add nineteen zeros at the right of M to make it 23 bits. e. The presentation is shown below: 3.49 The number is stored in the computer as

50 Example 3.24 Show the Excess_127 (single precision) representation of the decimal number Solution a. The sign is negative, so S = 1. b. Decimal to binary transformation: = ( ) 2. c. Normalization: ( ) 2 = ( ) d. E = = 134 = ( ) 2 and M = ( ) 2. e. Representation: 3.50 The number is stored in the computer as

51 Example 3.25 Show the Excess_127 (single precision) representation of the decimal number Solution a. S = 1 (the number is negative). b. Decimal to binary transformation: = ( ) 2. c. Normalization: ( ) 2 = (1.1) d. E = = 121 = ( ) 2 and M = (1) 2. e. Representation: 3.51 The number is stored in the computer as

52 Example 3.26 The bit pattern ( ) 2 is stored in Excess_127 format. Show the value in decimal. Solution a. The first bit represents S, the next eight bits, E and the remaining 23 bits, M. b. The sign is negative. c. The shifter = E 127 = = 21. d. This gives us ( ) e. The binary number is ( ) 2. f. The absolute value is 2,104, g. The number is 2,104,

53 3-3 STORING TEXT A section of text in any language is a sequence of symbols used to represent an idea in that language. For example, the English language uses 26 symbols (A, B, C,, Z) to represent uppercase letters, 26 symbols (a, b, c,, z) to represent lowercase letters, nine symbols (0, 1, 2,, 9) to represent numeric characters and symbols (.,?, :, ;,,!) to represent punctuation. Other symbols such as blank, newline, and tab are used for text alignment and readability. 3.54

54 We can represent each symbol with a bit pattern. In other words, text such as CATS, which is made up from four symbols, can be represented as four n-bit patterns, each pattern defining a single symbol (Figure 3.14). Figure 3.13 Representing symbols using bit patterns 3.55

55 3.56

56 Codes ASCII Unicode Other Codes i See Appendix A 3.57

57 3-4 STORING AUDIO Audio is a representation of sound or music. Audio is an example of analog data Figure 3.15 shows the nature of an analog signal, such as audio, that varies with time. 3.58

58 3.59 Figure 3.15 An audio signal

59 Sampling If we cannot record all the values of a an audio signal over an interval, we can record some of them. Sampling means that we select only a finite number of points on the analog signal, measure their values, and record them. Figure 3.16 Sampling an audio signal 3.60

60 Quantization The value measured for each sample is a real number. This means that we can store 40,000 real values for each one second sample. Quantization refers to a process that rounds the value of a sample to the closest integer value. For example, if the real value is 17.2, it can be rounded down to 17: if the value is 17.7, it can be rounded up to

61 Encoding The quantized sample values need to be encoded as bit patterns. Some systems assign positive and negative values to samples, some just shift the curve to the positive part and assign only positive values. If we call the bit depth or number of bits per sample B, the number of samples per second, S, we need to store S B bits for each second of audio. This product is sometimes referred to as bit rate, R. For example, if we use 40,000 samples per second and 16 bits per each sample, the bit rate is 3.62 R = 40, = 640,000 bits per second

62 Standards for sound encoding Today the dominant standard for storing audio is MP3 (short for MPEG Layer 3). This standard is a modification of the MPEG (Motion Picture Experts Group) compression method used for video. It uses samples per second and 16 bits per sample. The result is a signal with a bit rate of 705,600 bits per second, which is compressed using a compression method that discards information that cannot be detected by the human ear. This is called lossy compression, as opposed to lossless compression: see Chapter

63 3-5 STORING IMAGES Images are stored in computers using two different techniques: raster graphics and vector graphics Raster graphics Raster graphics (or bitmap graphics) is used when we need to store an analog image such as a photograph. A photograph consists of analog data, similar to audio information. The difference is that the intensity (color) of data varies in space instead of in time. This means that data must be sampled. However, sampling in this case is normally called scanning. The samples are called pixels (picture elements).

64 Resolution We need to decide how many pixels we should record for each square or linear inch. The scanning rate in image processing is called resolution. If the resolution is sufficiently high, the human eye cannot recognize the discontinuity in reproduced images. Color depth The number of bits used to represent a pixel, its color depth. Our eyes have different types of photoreceptor cells: three primary colors red, green and blue (often called RGB), while others merely respond to the intensity of light. 3.65

65 True-Color One of the techniques used to encode a pixel is called True- Color, which uses 24 bits to encode a pixel. 3.66

66 Indexed color The indexed color or palette color scheme uses only a portion of these colors. Figure 3.17 Relationship of the indexed color to the True-Color 3.67

67 For example, a high-quality digital camera uses almost three million pixels for a 3 5 inch photo. The following shows the number of bits that need to be stored using each scheme: 3.68

68 Standards for image encoding Several de facto standards for image encoding are in use. JPEG (Joint Photographic Experts Group) uses the True- Color scheme, but compresses the image to reduce the number of bits (see Chapter 15). GIF (Graphic Interchange Format), on the other hand, uses the indexed color scheme. 3.69

69 Vector graphics Raster graphics has two disadvantages: the file size is big and rescaling is troublesome. To enlarge a raster graphics image means enlarging the pixels, so the image looks ragged when it is enlarged. The vector graphic image :An image is decomposed into a combination of geometrical shapes such as lines, squares or circles. For example, consider a circle of radius r. The main pieces of information a program needs to draw this circle are: 1. The radius r and equation of a circle. 2. The location of the center point of the circle. 3. The stroke line style and color. 4. The fill style and color. 3.70

70 3-6 STORING VIDEO Video is a representation of images (called frames) over time. So, if we know how to store an image inside a computer, we also know how to store video: each image or frame is transformed into a set of bit patterns and stored. The combination of the images then represents the video. i See Chapter 15 for video compression. 3.71

### Introduction to Computer Science (I1100) Data Storage

Data Storage 145 Data types Data comes in different forms Data Numbers Text Audio Images Video 146 Data inside the computer All data types are transformed into a uniform representation when they are stored

### Objectives. Connecting with Computer Science 2

Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn how numbering systems are used to count Understand the significance of positional value

### 4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

### NUMBERS AND DATA REPRESENTATION. Introduction to Computer Engineering 2015 Spring by Euiseong Seo

NUMBERS AND DATA REPRESENTATION Introduction to Computer Engineering 2015 Spring by Euiseong Seo Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in other

### Data Representation and Networking

Data Representation and Networking Instructor: Dmitri A. Gusev Spring 2007 CSC 120.02: Introduction to Computer Science Lecture 3, January 30, 2007 Data Representation Topics Covered in Lecture 2 (recap+)

### 9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

### Data Representation 1

1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

### 4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.

Chapter 1 Data Storage 2007 Pearson Addison-Wesley. All rights reserved 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

### Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

1's column 10's column 100's column 1000's column 1's column 2's column 4's column 8's column Number Systems Decimal numbers 5374 10 = Binary numbers 1101 2 = Chapter 1 1's column 10's column 100's

### Chapter 4. Operations on Data

Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

### OBJECTIVES After reading this chapter, the student should be able to:

Data Representation OBJECTIVES After reading this chapter, the student should be able to: Define data types. Visualize how data are stored inside a computer. Understand the differences between text, numbers,

### UNIT 7A Data Representation: Numbers and Text. Digital Data

UNIT 7A Data Representation: Numbers and Text 1 Digital Data 10010101011110101010110101001110 What does this binary sequence represent? It could be: an integer a floating point number text encoded with

### Chapter 2. Data Representation in Computer Systems

Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

### Data Storage. Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J.

Data Storage Slides derived from those available on the web site of the book: Computer Science: An Overview, 11 th Edition, by J. Glenn Brookshear Copyright 2012 Pearson Education, Inc. Data Storage Bits

### 1. Which of the following Boolean operations produces the output 1 for the fewest number of input patterns?

This is full of Test bank for Computer Science An Overview 12th Edition by Brookshear SM https://getbooksolutions.com/download/computer-science-an-overview-12th-editionby-brookshear-sm Test Bank Chapter

### M1 Computers and Data

M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

### 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

### CSE COMPUTER USE: Fundamentals Test 1 Version D

Name:, (Last name) (First name) Student ID#: Registered Section: Instructor: Lew Lowther Solutions York University Faculty of Pure and Applied Science Department of Computer Science CSE 1520.03 COMPUTER

### Floating Point Arithmetic

Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

### Number Systems CHAPTER Positional Number Systems

CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

### Introduction to Computers and Programming. Numeric Values

Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000

### unused unused unused unused unused unused

BCD numbers. In some applications, such as in the financial industry, the errors that can creep in due to converting numbers back and forth between decimal and binary is unacceptable. For these applications

### Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

### Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

### IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

### a- As a special case, if there is only one symbol, no bits are required to specify it.

Codes A single bit is useful if exactly two answers to a question are possible. Examples include the result of a coin toss (heads or tails), Most situations in life are more complicated. This chapter concerns

### Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

### Jianhui Zhang, Ph.D., Associate Prof. College of Computer Science and Technology, Hangzhou Dianzi Univ.

Jianhui Zhang, Ph.D., Associate Prof. College of Computer Science and Technology, Hangzhou Dianzi Univ. Email: jh_zhang@hdu.edu.cn Copyright 2015 Pearson Education, Inc. Chapter 1: Data Storage Computer

### Bits and Bit Patterns

Bits and Bit Patterns Bit: Binary Digit (0 or 1) Bit Patterns are used to represent information. Numbers Text characters Images Sound And others 0-1 Boolean Operations Boolean Operation: An operation that

### CHW 261: Logic Design

CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

### IEEE Standard for Floating-Point Arithmetic: 754

IEEE Standard for Floating-Point Arithmetic: 754 G.E. Antoniou G.E. Antoniou () IEEE Standard for Floating-Point Arithmetic: 754 1 / 34 Floating Point Standard: IEEE 754 1985/2008 Established in 1985 (2008)

### CMPSCI 145 MIDTERM #2 SPRING 2017 April 7, 2017 Professor William T. Verts NAME PROBLEM SCORE POINTS GRAND TOTAL 100

CMPSCI 145 MIDTERM #2 SPRING 2017 April 7, 2017 NAME PROBLEM SCORE POINTS 1 15+5 2 25 3 20 4 10 5 18 6 12 GRAND TOTAL 100 15 Points Answer 15 of the following problems (1 point each). Answer more than

### Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!

### Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Number Representation 2 1 Topics to be Discussed How are numeric data items actually

### Internal Data Representation

Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

### CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

1 CHAPTER TWO Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 2-1 Data Types 2-2 Complements 2-3 Fixed-Point Representation 2-4 Floating-Point Representation

### 4.1 QUANTIZATION NOISE

DIGITAL SIGNAL PROCESSING UNIT IV FINITE WORD LENGTH EFFECTS Contents : 4.1 Quantization Noise 4.2 Fixed Point and Floating Point Number Representation 4.3 Truncation and Rounding 4.4 Quantization Noise

### Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

### Announcement. (CSC-3501) Lecture 3 (22 Jan 2008) Today, 1 st homework will be uploaded at our class website. Seung-Jong Park (Jay)

Computer Architecture (CSC-3501) Lecture 3 (22 Jan 2008) Seung-Jong Park (Jay) http://www.csc.lsu.edu/~sjpark 1 Announcement Today, 1 st homework will be uploaded at our class website Due date is the beginning

### Signed Binary Numbers

Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

### CHAPTER 2 Data Representation in Computer Systems

CHAPTER 2 Data Representation in Computer Systems 2.1 Introduction 37 2.2 Positional Numbering Systems 38 2.3 Decimal to Binary Conversions 38 2.3.1 Converting Unsigned Whole Numbers 39 2.3.2 Converting

### Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15

### Chapter 4: Data Representations

Chapter 4: Data Representations Integer Representations o unsigned o sign-magnitude o one's complement o two's complement o bias o comparison o sign extension o overflow Character Representations Floating

### A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Complement Number Systems A complement number system is used to represent positive and negative integers A complement number system is based on a fixed length representation of numbers Pretend that integers

### CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

### ±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j

ENEE 350 c C. B. Silio, Jan., 2010 FLOATING POINT REPRESENTATIONS It is assumed that the student is familiar with the discussion in Appendix B of the text by A. Tanenbaum, Structured Computer Organization,

### Chapter 2 Bits, Data Types, and Operations

Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

### Floating Point Arithmetic

Floating Point Arithmetic Clark N. Taylor Department of Electrical and Computer Engineering Brigham Young University clark.taylor@byu.edu 1 Introduction Numerical operations are something at which digital

### COMP Overview of Tutorial #2

COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

### Module 2: Computer Arithmetic

Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

### CMPSCI 145 MIDTERM #2 Solution Key SPRING 2018 April 13, 2018 Professor William T. Verts

CMPSCI 145 MIDTERM #2 Solution Key SPRING 2018 April 13, 2018 10 Points Answer 10 of the following problems (1 point each). Answer more than 10 for extra credit. Scoring will be +1 for each correct

### The type of all data used in a C (or C++) program must be specified

The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

### Digital Fundamentals

Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted

### DigiPoints Volume 1. Student Workbook. Module 8 Digital Compression

Digital Compression Page 8.1 DigiPoints Volume 1 Module 8 Digital Compression Summary This module describes the techniques by which digital signals are compressed in order to make it possible to carry

### Inf2C - Computer Systems Lecture 2 Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack

### Administrivia. CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries. Representing characters DATA REPRESENTATION

Administrivia CMSC 216 Introduction to Computer Systems Lecture 24 Data Representation and Libraries Jan Plane & Alan Sussman {jplane, als}@cs.umd.edu Project 6 due next Friday, 12/10 public tests posted

### Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

1 Floating Point The World is Not Just Integers Programming languages support numbers with fraction Called floating-point numbers Examples: 3.14159265 (π) 2.71828 (e) 0.000000001 or 1.0 10 9 (seconds in

### D I G I T A L C I R C U I T S E E

D I G I T A L C I R C U I T S E E Digital Circuits Basic Scope and Introduction This book covers theory solved examples and previous year gate question for following topics: Number system, Boolean algebra,

### ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

### 2nd Paragraph should make a point (could be an advantage or disadvantage) and explain the point fully giving an example where necessary.

STUDENT TEACHER WORKING AT GRADE TERM TARGET CLASS YEAR TARGET The long answer questions in this booklet are designed to stretch and challenge you. It is important that you understand how they should be

### 15 Data Compression 2014/9/21. Objectives After studying this chapter, the student should be able to: 15-1 LOSSLESS COMPRESSION

15 Data Compression Data compression implies sending or storing a smaller number of bits. Although many methods are used for this purpose, in general these methods can be divided into two broad categories:

### CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation

CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation George Tsiknis University of British Columbia Department of Computer Science Winter Term 2, 2015-2016 Last updated: 04/04/2016

### Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Representing Information 0 1 0 Bit Juggling 1 1 - Representing information using bits - Number representations 1 - Some other bits 0 0 - Chapters 1 and 2.3,2.4 Motivations Computers Process Information

### Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

Announcements Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit Quiz 2 Monday on Number System Conversions

### Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

### Signed umbers. Sign/Magnitude otation

Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

### COMPUTER ORGANIZATION AND ARCHITECTURE

COMPUTER ORGANIZATION AND ARCHITECTURE For COMPUTER SCIENCE COMPUTER ORGANIZATION. SYLLABUS AND ARCHITECTURE Machine instructions and addressing modes, ALU and data-path, CPU control design, Memory interface,

### COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

### Bits, Words, and Integers

Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

### CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

### UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and

### CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

### 15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2

15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2 Name Section Directions: Answer each question neatly in the space provided. Please read each question carefully. You have 50 minutes for this exam. No electronic

### IBM 370 Basic Data Types

IBM 370 Basic Data Types This lecture discusses the basic data types used on the IBM 370, 1. Two s complement binary numbers 2. EBCDIC (Extended Binary Coded Decimal Interchange Code) 3. Zoned Decimal

### COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Computer Arithmetic Data is manipulated by using the arithmetic instructions in digital computers. Data is manipulated to produce results necessary to give solution for the computation problems. The Addition,

In this lesson you will learn: how to add and multiply positive binary integers how to work with signed binary numbers using two s complement how fixed and floating point numbers are used to represent

### CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS

CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS INTRODUCTION Digital computers use sequences of binary digits (bits) to represent numbers, letters, special symbols, music, pictures, and videos.

### Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/571/

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Lisa Ossian, Minsub Shin, Sujith Surendran Midterm Examination 1 In Class (50 minutes) Wednesday,

### CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2015 April 3, 2015 Professor William T. Verts

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2015 April 3, 2015 Page 1 15 Points Answer 15 of the following problems (1 point each). Answer more than 15 for extra credit. Incorrect or blank answers will

### Data Representation From 0s and 1s to images CPSC 101

Data Representation From 0s and 1s to images CPSC 101 Learning Goals After the Data Representation: Images unit, you will be able to: Recognize and translate between binary and decimal numbers Define bit,

### Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

### Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Data Representation ti and Arithmetic for Computers Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Questions What do you know about

### Introduction to Computer Science-103. Midterm

Introduction to Computer Science-103 Midterm 1. Convert the following hexadecimal and octal numbers to decimal without using a calculator, showing your work. (6%) a. (ABC.D) 16 2748.8125 b. (411) 8 265

### Binary representation and data

Binary representation and data Loriano Storchi loriano@storchi.org http:://www.storchi.org/ Binary representation of numbers In a positional numbering system given the base this directly defines the number

### Chapter 2. Data Representation in Computer Systems

Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

### CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

CMPSCI 145 MIDTERM #1 Solution Key NAME SPRING 2017 March 3, 2017 PROBLEM SCORE POINTS 1 10 2 10 3 15 4 15 5 20 6 12 7 8 8 10 TOTAL 100 10 Points Examine the following diagram of two systems, one involving

### CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

### Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan Administrivia Lab

### CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2016 March 30, 2016 Professor William T. Verts

CMPSCI 145 MIDTERM #2 SOLUTION KEY SPRING 2016 March 30, 2016 Items in red are students expected answers or instructions on scoring to the grader. Items in light blue are my annotations or explanations,

### Chapter 2. Positional number systems. 2.1 Signed number representations Signed magnitude

Chapter 2 Positional number systems A positional number system represents numeric values as sequences of one or more digits. Each digit in the representation is weighted according to its position in the

### Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Digital Logic 1 Data Representations 1.1 The Binary System The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. The system we

### Logic, Words, and Integers

Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits

### COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

### Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

### Lecture 8 JPEG Compression (Part 3)

CS 414 Multimedia Systems Design Lecture 8 JPEG Compression (Part 3) Klara Nahrstedt Spring 2012 Administrative MP1 is posted Today Covered Topics Hybrid Coding: JPEG Coding Reading: Section 7.5 out of