290 likes | 611 Views
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. In the binary number system, all values are represented using only the two binary digits 0 and 1
E N D
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 • In the binary number system, all values are represented using only the two binary digits 0 and 1 • “bit” is a contraction of “binary digit”
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
Binary Numbers 3-bit numbers can represent 8=23 different numbers • 000 - 0 • 001 - 1 • 010 - 2 • 011 - 3 • 100 - 4 • 101 - 5 • 110 - 6 • 111 - 7
Decimal Numbers • Place system 123 = 1x100 + 2x10 + 3x1 = 1x102 + 2x101+ 3x100
Binary representation • Subscript tells you which representation • Put little powers of 2 on top of column
Converting binary to decimal • The second line has an error • You do some (using little powers of 2 on top)
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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
Compression • Graphics (picture), music and video files are very large. • File compression techniques are used to reduce the storage requirements for large files
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
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.