data representation and storage lecture 5. representations a number value can be represented in many...

23
Data Representation and Storage Lecture 5

Upload: sherman-sparks

Post on 30-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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 and Storage

Lecture 5

Page 2: 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

Representations A number value can be represented

in many ways:5FiveVIIIIICinqHold up my hand

Page 3: 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

Binary NumbersIn the binary number system, all

values are represented using only the two binary digits 0 and 1

“bit” is a contraction of “binary digit”

Page 4: 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

Binary Numbers

1-bit numbers can represent 2=21 different numbers

0 - 0 1 – 1

2-bit numbers can represent 4=22 different numbers

00 - 0 01 - 1 10 - 2 11 - 3

Page 5: 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

Binary Numbers3-bit numbers can represent 8=23 different

numbers 000 - 0 001 - 1 010 - 2 011 - 3 100 - 4 101 - 5 110 - 6 111 - 7

Page 6: 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

Decimal Numbers

Place system

123 = 1x100 + 2x10 + 3x1

= 1x102 + 2x101+ 3x100

Page 7: 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

Binary representation

Subscript tells you which representation Put little powers of 2 on top of column

Page 8: 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

Converting binary to decimal

The second line has an error You do some (using little powers of 2 on top)

Page 9: 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

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.

Page 10: 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

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 bit pattern.

Page 11: 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

ASCII

Page 12: 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

Bit

A bit is the smallest unit of memory in the computer.

It can take the value 1 or 0. All data in a computer is represented as a

pattern of bits.

Page 13: 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

Byte

A group of 8 bits is called a byte. Since each bit can be either 0 or 1, there

are 256 different bit patterns that can be represented using 8 bits.

A nybble is 4 bits.

Page 14: 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

Unicode

An extension of ASCII A 16-bit character encoding scheme. Uses 2 bytes for each character Allows more characters from major world

languages to be encoded.

Page 15: 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

ASCII file

A document that contains plain text only (such as a Notepad file – even html) is called an ASCII file or a text file. Each character of text is stored as one ASCII pattern, in one byte of memory. So a file containing 20 lines of text, with 100 characters per line, would be stored in 2000 bytes.

Page 16: 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

SIZE

The size of a file = number of bytes stored in the file.

For ASCII text files, the size of the file = number of characters.

Page 17: 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

SIZE

1KB = 1 Kilobyte = 1,024 bytes = 210 bytes (a page of 20 lines of text, about 100 chars per line, would be about 2 KB)

1MB = 1 Megabyte = 1,024 KB = 220 bytes (about 1,000 pages of text would be about 2MB)

1GB = 1 Gigabyte = 1,024 MB = 230 bytes

Page 18: 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

Binary files

Computers are capable of representing much more than numbers and text.

If you try to open a Word document in Notepad, sometimes you see garbage characters because those bytes don't correspond to ASCII codes.

Page 19: 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

Binary Files

Files that contain anything except plain text (e.g. formatted Word documents, executable program files or pictures) are not stored as ASCII files.

But the information is still stored in a type of binary format. They are called binary files.

Page 20: 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

Graphics

"A picture is worth 1,000 words" - Actually, computer scientists would say that it is worth more! 1,000 words, at an average of 5 chars per word = 5,000 chars = about 5KB. That's enough for a very, very tiny picture. Most graphics on the web are over 30KB!

high-resolution vs. low-resolution -> tradeoff of image quality vs. storage space

Page 21: 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

Compression

Graphics (picture), music and video files are very large.

File compression techniques are used to reduce the storage requirements for large files

Page 22: 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

Speed of data transmission

Data is transmitted at speeds that are measured in terms of bps- bits per second.

The time it takes to download a file depends on the size of the file and the speed of the transmission. Compression reduces file size and thus the time it takes to transmit.

Waterpipe analogy- empty tank

Page 23: 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

Speed of data transmission

When you connect to the Internet: Modem (define ?) - 28.8Kbps, 56Kbps Faster means such as

Cable modem- uses part of the capacity of the local cable system to transmit data

DSL (Digital Subscriber Line) -a technology that allows high speed data transmission over telephone lines.