1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN 0-13-046709-X Chapter 12 Data Representation.

Slides:



Advertisements
Similar presentations
Dale & Lewis Chapter 3 Data Representation Analog and digital information The real world is continuous and finite, data on computers are finite  need.
Advertisements

Information Representation
Technology ICT Option: Data Representation. Data Representation In our everyday lives, we communicate with each other using analogue data. This data takes.
3.1 3 Data Storage Foundations of Computer Science  Cengage Learning.
The Binary Numbering Systems
Comp 1001: IT & Architecture - Joe Carthy 1 Review Floating point numbers are represented in scientific notation In binary: ± m x 2 exp There are different.
Connecting with Computer Science, 2e
1 The Information School of the University of Washington Nov 6fit more-digital © 2006 University of Washington Digital Information INFO/CSE 100,
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 12 Data.
Introduction to Information Technology
IT-101 Section 001 Lecture #4 Introduction to Information Technology.
Digital Data Patrice Koehl Computer Science UC Davis.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Chapter 5 Data representation.
Department of Physics and Astronomy DIGITAL IMAGE PROCESSING
Higher Computing Data Representation.
Lecture 5.
COMP Representing Sound in a ComputerSound Course book - pages
CSCI-235 Micro-Computers in Science Hardware Part II.
Computers and Scientific Thinking David Reed, Creighton University Data Representation 1.
Computer Some basic concepts. Binary number Why binary? Look at a decimal number: 3511 Look at a binary number: 1011 counting decimal binary
Announcements Chapter 11 for today No quiz this week Instructor got behind…. We'll be back in MGH389 on Friday.
Chapter 11 Fluency with Information Technology 4 th edition by Lawrence Snyder (slides by Deborah Woodall : 1.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 14 Introduction to Computer Graphics.
Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy.
Chapter 2 Computer Hardware
Data Representation CS280 – 09/13/05. Binary (from a Hacker’s dictionary) A base-2 numbering system with only two digits, 0 and 1, which is perfectly.
Data Representation and Storage Lecture 5. Representations A number value can be represented in many ways: 5 Five V IIIII Cinq Hold up my hand.
Data Representation The method of data representation in a computer system depends upon the type of data which is being used. Three types of data are considered.
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Chapter 2 : Business Information Business Data Communications, 6e.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Marr CollegeHigher ComputingSlide 1 Higher Computing: COMPUTER SYSTEMS Part 1: Data Representation – 6 hours.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Data Representation, Number Systems and Base Conversions
Data Representation Robin Burke IT 130. Outline Data Representation Binary Numbers Image types.
Data Representation The storage of Text Numbers Graphics.
Marwan Al-Namari 1 Digital Representations. Bits and Bytes Devices can only be in one of two states 0 or 1, yes or no, on or off, … Bit: a unit of data.
CSCI-100 Introduction to Computing Hardware Part II.
Chapter 1 Background 1. In this lecture, you will find answers to these questions Computers store and transmit information using digital data. What exactly.
COMP135/COMP535 Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 2 Lecture 2 – Digital Representations.
Chapter 1 Data Storage © 2007 Pearson Addison-Wesley. All rights reserved.
Software Design and Development Storing Data Part 2 Text, sound and video Computing Science.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Data Representation. In our everyday lives, we communicate with each other using analogue data. This data takes the form of: Sound Images Letters Numbers.
Chapter 1: Data Storage.
Computer Science: An Overview Eleventh Edition
Invitation to Computer Science, C++ Version, Fourth Edition
Data Representation.
Lec 3: Data Representation
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
Level 3 Extended Diploma Unit 19 Computer Systems Architecture
INFS 211: Introduction to Information Technology
3.1 Denary, Binary and Hexadecimal Number Systems
3 Data Storage Foundations of Computer Science ã Cengage Learning.
Chapter 3 Data Storage.
Information Support and Services
Intermediate 2 Computing
Chapter 3: Data Representation
Web Design and Development
Summer Term Year 10 Slides
Computer Systems – Unit 1
Information Representation
Chapter 2 Data Representation.
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Option: Data Representation
Option: Data Representation
CSCI-235 Micro-Computer Applications
Presentation transcript:

1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 12 Data Representation

2 Analog vs. Digital there are two ways data can be stored electronically 1. analog signals represent data in a way that is analogous to real life signals can vary continuously across an infinite range of values e.g., frequencies on an old-fashioned radio with a dial 2. digital signals utilize only a finite set of values e.g., frequencies on a modern radio with digital display) the major tradeoff between analog and digital is variability vs. reproducibility analog allows for a (potentially) infinite number of unique signals, but they are harder to reproduce  good for storing data that is highly variable but does not need to be reproduced exactly digital signals limit the number of representable signals, but they are easily remembered and reproduced  good for storing data when reproducibility is paramount

3 Binary Numbers modern computers save and manipulate data as discrete (digital) values the most effective systems use two distinct binary states for data representation in essence, all data is stored as binary numbers in the binary number system, all values are represented using only the two binary digits 0 and 1, which are called bits binary representation converting binary to decimal

4 Decimal  Binary algorithm for converting from decimal (D) to binary (B):

8-5 The 16 Hex Digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F A = 10, B = 11,..., F = 15 Sixteen values can be represented perfectly by 4-bit sequences (2 4 = 16) Changing hex digits to bits and back again: Given a sequence of bits, group them in 4's and write the corresponding hex digit  C Given hex, write the associated group of 4 bits

8-6 Hex (0-9,A-F) Decimal HexBinary A B C D E F 1111

7 Representing Integers when an integer value must be saved on a computer, its binary equivalent can be encoded as a bit pattern and stored digitally usually, a fixed size (e.g., 32 bits) is used for each integer so that the computer knows where one integer ends and another begins the initial bit in each pattern acts as the sign bit (0=positive, 1=negative) negative numbers are represented in two’s complement notation  the "largest" bit pattern corresponds to the smallest absolute value (-1)

8 Representing Real Numbers a real number can be uniquely identified by the two components of its scientific notation (fractional part and the exponent) = x = 42 x 10 6 thus, any real number can be stored as a pair of integers real numbers stored in this format are known as floating point numbers, since the decimal point moves (floats) to normalize the fraction standard formats exist for storing real numbers, using either 32 bits (single precision) or 64 bits (double precision) most programming languages represent integers and reals differently JavaScript simplifies things by using IEEE double-precision floating point for all numbers

9 Representing Characters characters have no natural correspondence to binary numbers computer scientists devised an arbitrary system for representing characters as bit patterns ASCII (American Standard Code for Information Interchange)  maps each character to a specific 8-bit pattern  note that all digits are contiguous, as are all lower-case and all upper- case letters '0' < '1' < … < '9' 'A' < 'B' < … < 'Z' 'a' < 'b' < … < 'z'

10 Representing Text strings can be represented as sequences of ASCII codes, one for each character in the string specific programs may store additional information along with the ASCII codes e.g. programming languages will often store the number of characters along with the ASCII codes e.g., word processing programs will insert special character symbols to denote formatting (analogous to HTML tags in a Web page)

11 Representing Text The size of a file = number of bytes stored in the file. For plain ASCII text files, the size of the file = number of characters. Word processing documents are larger because of the extra formatting information that is part of the file. 1KB (kilobyte) = 2 10 bytes = 1024 bytes (a file of 20 lines of text, about 100 chars per line, would be about 2 KB) 1MB (megabyte) = 2 20 bytes = 1024KB (about 1,000 pages of text, each page 20 lines of 100 chars, would be about 2MB) 1GB (gigabyte) = 2 30 bytes = 1024MB 1TB (terabyte) = 2 40 bytes = 1024GB Speed of Data Transmission: Data are transmitted at speeds measured in bps (bits per second). Typical Speeds: Modem Kbps, 56Kbps ISDN - 64Kbps, DSL - 768Kbps – 3Mbs Cable Modem - > 3Mbs

8-12 The 16 Hex Digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F A = 10, B = 11,..., F = 15 Sixteen values can be represented perfectly by 4-bit sequences (2 4 = 16) Changing hex digits to bits and back again: Given a sequence of bits, group them in 4's and write the corresponding hex digit  C

8-13 Hex (0-9,A-F) Decimal HexBinary A B C D E F 1111

Binary - HEX – Binary Example: ( ) 2 = (?) = (4 2 A 5 6 F 1) 16 Example: (AF52C) 16 = (?) 2 A F 5 2 C = ( ) 2 14

11-15 Digitizing Sound An object creates sound by vibrating in a medium such as air Vibrations push the air Pressure waves emanate from the object and vibrate our eardrums The force, or intensity of the push determines the volume The frequency (number of waves per second) is the pitch

11-16 Analog Sound

11-17 Sampling Take measurements at regular intervals Number of samples in a second is the sampling rate The faster the rate, the more accurate the recording

18 Representing Sounds computers are capable of representing much more than numbers and text complex data requires additional techniques and algorithms EXAMPLE: representing sounds sounds are inherently analog signals with a specific amplitudes and frequencies when sound waves reach your ear, they cause your eardrum to vibrate, and your brain interprets the vibration as sound e.g. telephones translate a waveform into electrical signals, which are then sent over a wire and converted back to sound e.g. phonographs interpret waveforms stored on on grooves of a disk (similar to audio cassettes) analog signals cannot be reproduced exactly, but this is not usually a problem since the human ear is unlikely to notice small inconsistencies

19 Representing Sounds (cont.) when analog recordings are repeatedly duplicated, small errors that were originally unnoticed begin to propagate digital recordings can be reproduced exactly without any deterioration in sound quality  analog waveforms must be converted to a sequence of discrete values  digital sampling is the process in which the amplitude of a wave is measured at regular intervals, and stored as discrete measurements  frequent measurements must be taken to ensure high quality  this results in massive amounts of storage  techniques are used to compress the data and reduce file sizes (e.g., MP3, WAV)

11-20 Analog –Digital - Analog

11-21 How Many Bits per Sample? How accurate must the samples be? Bits must represent both positive and negative values The more bits, the more accurate the measurement The digital representation of audio CDs uses 16 bits (records 65,536 levels, half above and half below the zero line)

11-22 Digitizing Sound

11-23 Advantages of Digital Sound We can compute the representation MP3 Compression One computation is to compress the digital audio (reduce number of bits needed) Remove waves that are outside range of human hearing MP3 usually gets a compression rate of 10:1  Lower bandwidth requirements, popular for Internet transmission Reproducing the Sound Recording Bit file can be copied without losing any information Original and copy are exactly the same

24 Representing Images EXAMPLE: representing images images are stored using a variety of formats and compression techniques the simplest representation is a bitmap bitmaps partition an image into a grid of spots, 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

25 Representing Images (cont.) when creating a bitmap of a color image, more than one bit is required to represent each pixel the most common system is to translate each pixel into a 24 bit code, known as its RGB value: 8 bits to represent the intensity of each red/green/blue component common image formats implement various compression techniques to reduce storage size GIF (Graphics Interchange Format)  a lossless format, meaning no information is lost in the compression  commonly used for precise pictures, such as line drawings JPEG (Joint Photographic Experts Group)  a lossy format, so the compression is not fully reversible (but more efficient)  commonly used for photographs

26 Distinguishing Data Types how does a computer know what type of value is stored in a particular piece of memory? short answer: it doesn't when a program stores data in memory, it must store additional information as to what type of data the bit pattern represents thus, the same bit pattern might represent different values in different contexts

11-27 Distinguishing Data Types