Introduction to Computer Science (I1100) Data Storage

Similar documents
3 Data Storage 3.1. Foundations of Computer Science Cengage Learning

Data Representation 1

Binary representation and data

Objectives. Connecting with Computer Science 2

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

Data Representation and Networking

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

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

Bits, bytes, binary numbers, and the representation of information

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

DigiPoints Volume 1. Student Workbook. Module 8 Digital Compression

Chapter 1. Data Storage Pearson Addison-Wesley. All rights reserved

CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS

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

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

Bits and Bit Patterns

Logo & Icon. Fit Together Logo (color) Transome Logo (black and white) Quick Reference Print Specifications

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

Groups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...

Elementary Computing CSC 100. M. Cheng, Computer Science

Standard File Formats

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

CSE COMPUTER USE: Fundamentals Test 1 Version D

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

Common Technology Words and Definitions

Learning Programme Fundamentals of data representation AS Level

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

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

Final Study Guide Arts & Communications

Chapter 2 Bits, Data Types, and Operations

OCR J276 GCSE Computer Science

255, 255, 0 0, 255, 255 XHTML:

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

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

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

Lecture 8 JPEG Compression (Part 3)

General Computing Concepts. Coding and Representation. General Computing Concepts. Computing Concepts: Review

Compression; Error detection & correction

color bit depth dithered

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

Multimedia applications

Data encoding. Lauri Võsandi

CHAPTER 2 Data Representation in Computer Systems

Computing in the Modern World

CHAPTER 2 Data Representation in Computer Systems

Robert Matthew Buckley. Nova Southeastern University. Dr. Laszlo. MCIS625 On Line. Module 2 Graphics File Format Essay

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

15110 Principles of Computing, Carnegie Mellon University - CORTINA. Digital Data

Compression; Error detection & correction

The Core Technology of Digital TV

MULTIMEDIA AND CODING

Chapter 2. Data Representation in Computer Systems

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

CS311 Lecture: Representing Information in Binary Last revised 8/2707

Multimedia on the Web

Computer Science 1000: Part #3. Binary Numbers

"Digital Media Primer" Yue- Ling Wong, Copyright (c)2011 by Pearson EducaDon, Inc. All rights reserved.

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

Digital Data. 10/11/2011 Prepared by: Khuzaima Jallad

Representation of Non Negative Integers

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Numeral Systems (Part II)

Software and Hardware

Compression Part 2 Lossy Image Compression (JPEG) Norm Zeck

Image coding and compression

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

Wireless Communication

Features. Sequential encoding. Progressive encoding. Hierarchical encoding. Lossless encoding using a different strategy

World Inside a Computer is Binary

UNIVERSITY OF WISCONSIN MADISON

IEEE Standard for Floating-Point Arithmetic: 754

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

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

ITP 140 Mobile App Technologies. Colors

COMP2611: Computer Organization. Data Representation

This document contains additional questions; it is not intended to be treated as a complete paper.

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Signed umbers. Sign/Magnitude otation

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

COMP Overview of Tutorial #2

Quiz on Ch.2. Convert to decimal

8/31/2015 BITS BYTES AND FILES. What is a bit. Representing a number. Technically, it s a change of voltage

Unicode. Standard Alphanumeric Formats. Unicode Version 2.1 BCD ASCII EBCDIC

Chapter 4. Operations on Data

This is not yellow. Image Files - Center for Graphics and Geometric Computing, Technion 2

MEDIA RELATED FILE TYPES

Chapter 1. Digital Data Representation and Communication. Part 2

Lecture 06. Raster and Vector Data Models. Part (1) Common Data Models. Raster. Vector. Points. Points. ( x,y ) Area. Area Line.

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

Chapter 2 Data Representations

Digital Media. Daniel Fuller ITEC 2110

CS101 Lecture 12: Image Compression. What You ll Learn Today

M1 Computers and Data

Prentice Hall. Learning Microsoft PowerPoint , (Weixel et al.) Arkansas Multimedia Applications I - Curriculum Content Frameworks

Flying Start AS Computer Science. September 2015

What is multimedia? Multimedia. Continuous media. Most common media types. Continuous media processing. Interactivity. What is multimedia?

Example 1: Denary = 1. Answer: Binary = (1 * 1) = 1. Example 2: Denary = 3. Answer: Binary = (1 * 1) + (2 * 1) = 3

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

CPS311 Lecture: Representing Information in Binary Last revised Sept. 25, 2017

Data Representations & Arithmetic Operations

Transcription:

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 in a computer and transformed back to their original form when retrieved. This universal representation is called bit pattern. Bit: (binary digit) is the smallest unit of data that can be stored in a computer and has value of 0 or 1. (based on switches on/off) To represent different types of data, we use bit pattern, a sequence (string of bits). A bit pattern with 8 bits is called a byte. 147

Storing numbers A number is changed to the binary system before being stored in the computer s memory. However, 2 issues need to be handled: 1. How to store the sign of a number? 2. How to show the decimal point? 148

Storing Integers Integers are whole numbers (without a fractional part). Example: 134-125 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 bit (rightmost). A fixed-point representation is used to store an integer (the decimal point is assumed but not stored) 0 1 0 1 1 0 0 0 0 Memory location Decimal point (assumed position) 149

Storing Integers 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. Since no computer can possibly represent all the integers in this range, most computers define a constant called the maximum unsigned integer. Maximum unsigned integer = 2 n -1 where n is the number of bits allocated to represent an unsigned integer. 150

Storing unsigned integers To store an unsigned integer, follow these steps: 1. The integer is changed to binary 2. If the number of bits is less than n, 0s are added to the left of the binary integer so that there is a total of n bits. If the number of bits is greater than n, the integer cannot be stored. Overflow. 151

Storing unsigned integers Example Store 7 in a 8-bit memory location using unsigned representation. Solution: 1. Change the integer to binary : (111) 2 2. Add five 0s to the left to make a total of 8 bits: (00000111) 2 152

Storing unsigned integers Overflow In a n-bit memory, we can store an unsigned integer between 0 and 2 n -1. Example: in a 4-bit memory, the larger integer that can be stored is 2 4-1=15 What if we store 20? 20 = (10100) 2 The computer drops the leftmost bit and keeps the rightmost 4 bits (0100) 2 =4 153

Storing signed integers All computers uses two s complement representation to store a signed integer in a n-bit memory. In this method, the available range of an unsigned integer is divided into two equal subranges. The first subrange is used to represent positive integers the second subrange is used to represent negatives integers 154

Storing signed integers Example If n=4, the range is 0000 to 1111. This range is divided into two halves: 0000 to 0111, and 1000 to 1111 The first leftmost bit determines the sign. If the leftmost bit is 0, the integer is positive if the leftmost bit is 1, the integer is negative 155

Storing signed integers Two complement operation Copy bits from the right until a 1 is copied, then flip the rest of the bits. Example 0 0 1 1 0 1 0 0 1 1 0 0 1 1 0 0 156

Storing an integer in two s complement format To store an integer in two s complement format, follow these steps: 1. The integer is changed to n-binary format 2. If the integer is positive or zero, it is stored as it is If the integer is negative, the computer takes the two s complement of the integer and stores it. 157

Retrieving an integer in two s complement format To retrieve an integer in two s complement format, follow these steps: 1. If the leftmost bit is 1, the computer applies the two s complement operation to the integer If the leftmost bit is 0, no operation is applied 2. The computer changes the integer to decimal. 158

Storing signed integers Two complement operation - EXAMPLE Store the integer 28 in a 8-bit memory location using two s complement representation. Solution: The integer is positive. After decimal to binary transformation no more action is needed. We need to add 3 extra 0s to the left to the integer to make it 8 bits. 28 = (00011100) 2 159

Storing signed integers Two complement operation - EXAMPLE Store the integer -28 in a 8-bit memory location using two s complement representation. Solution: The integer is negative. After decimal to binary transformation, the computer applies the two s complement operation. Change 28 to binary = (00011100) 2 apply two s complement operation = (11100100) 2 160

Retrieving signed integers Two complement operation - EXAMPLE Retrieve the integer that is stored as (11100110) 2 in memory using two s complement representation. Solution: The leftmost bit is 1, so the integer is negative. The integer needs to be two s complemented before changing to decimal (11100110) 2 apply two s complement operation = (00011010) 2 integer changed to decimal = 26 sign is added = - 26 161

Storing reals A real is a number with an integral part and a fractional part. The fixed-point representation can be used, however the result may not be accurate. Example: * if we reserve 2 digits to the right of the decimal point, the system will store 1.00234 as 1.00 * if we reserve 6 digits to the left of the decimal point, the system will store 1234567.00 as 234567.00 As a rule: real numbers with very large integral parts or very small fractional parts should not be stored in fixed-point representation. 162

Storing reals Floating-point representation This representation allows the decimal point to float: we can have different numbers of digits to the left or right of the decimal point. In this representation, either decimal or binary, a number is made up of 3 sections Sign Shifter Fixed-point number 163

Storing texts We represent each symbol with a bit pattern. Example: CATS C A T S 1000011 1000001 1010100 1010011 How many bits are needed in a bit-pattern to represent a symbol in a language? It depends on the number of symbols in that language. The relation is logarithmic If we need 2 symbols the length is 1 bit (log 2 2 = 1) If we need 4 symbols the length is 2 bits (log 2 4 = 2) 164

Number of symbols and bit pattern length Number of Symbols Bit pattern length Number of Symbols Bit pattern length 2 1 128 7 4 2 256 8 8 3 65,536 16 16 4 4,294,967,296 32 ASCII CODE UNICODE 165

ASCII Table 166

Unicode 167

Storing Audio Audio is a representation of sound or music. Audio is not countable. Audio is an entity that changes with time. We measure its intensity at each moment. Storing audio in computer memory = storing the intensity of an audio signal over a period of time. Audio is an example of analog data (text, numbers are digital data) Even if we are able to measure all its values in a period of time, we cannot store these as we would need infinite number of memory locations. 168

Storing Audio 169

Storing Audio Step 1 : Sampling Sampling rate 40,000 samples per second 170

Storing Audio Step 2 : Quantization The value for each sample is a real number. Quantization = use an unsigned integer for each sample 171

Storing Audio Step 3 : Encoding Encoding : Quantized sample need to be encoded as bit patterns 172

Storing Audio Bit depth (B) : number of bits allocated for each sample (nowadays 16, 32 bits) Bit rate : we need to store S*B bits for each second of audio (S = number of samples per second) Example: if we use 40,000 samples per second and 16bits per each sample, the bit rate is R = 40,000*16=640,000 bits per second = 640 kilobits per second 173

MP3 Dominant standard for storing audio is MP3 (MPEG layer 3). This standard is a modification of the MPEG (Motion Picture Experts Group) compression method used for video. It uses 44,100 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 (called lossy compression) 174

Storing Images Images are stored in computers using 2 different techniques: raster images and vector images (we will not cover vector images). 175

Raster images / Bitmap images Used to store an analog image such as a photograph. Photograph = analog data, the intensity of data (color) varies in space. Data must be sampled. Here it is called Scanning. Samples are called pixels (picture elements). The whole image is divided into small pixels where each pixel have a single intensity value. 176

Resolution Just like audio sampling, we need to decide how many pixels we need to record for each square. Scanning rate in image processing is called resolution. 177

Color Depth Color depth = number of bits to represent a pixel, depends on how a pixel s color is handled by different encoding techniques. Our eyes have different types of photoreceptor cells where some respond to the 3 primary colors red, green and blue (called RGB). 178

Color encoding technique True-color True-color uses 24 bits to encode a pixel. Each of the primary colors (RGB) are represented by 8 bits (each color is represented by 3 decimals between 0 and 255) Color Red Green Blue Color Red Green Blue Black 0 0 0 Yellow 255 255 0 Red 255 0 0 Cyan 0 255 255 Green 0 255 0 Magenta 255 0 255 Blue 0 0 255 White 255 255 255 True-color scheme can encode 2 24 = 16,776,226 colors (the color intensity of each pixel is one of these values). 179

Color encoding technique Indexed color Many applications do not need such large range of colors. The indexed color (palette color) uses only a portion of these colors (normally 256 colors only) The index scheme uses only 8 bits to store the sample pixel. 180

JPEG GIF JPEG (Joint Photographic Experts Group) uses the True-Color scheme, but compresses the image to reduce the number of bits. GIF (Graphic Interchange Format) uses the indexed color scheme. 181

Storing Video Video is a representation if images (called frames) over time. Movie = series of frames shown one after another to create the illusion of motion. Video = representation of information that changes in space (single image) and in time (a series of image) Each image or frame is transformed into a set of bit patterns and stored. The combination represents the video. Today video is normally compressed. Example: MPEG is a common video compression technique. 182