Information Representation 1 Computer Architecture 2 Memory Memory

  • Slides: 21
Download presentation
Information Representation 1

Information Representation 1

Computer Architecture 2

Computer Architecture 2

Memory • Memory is a collection of cells, each with a unique physical address

Memory • Memory is a collection of cells, each with a unique physical address for random (direct) access • memory is divided into fixed-length units or words • Information that is stored in memory cells is in binary coded format: – Instructions that make up programs – Data: text symbols, numbers, images, etc.

Information Representation • The Binary System: Using On/Off Electrical States to Represent Data &

Information Representation • The Binary System: Using On/Off Electrical States to Represent Data & Instructions • The binary system has only two digits--0 and 1. • Bit - binary digit • Byte - group of 8 bits used to represent one character, digit, or other value 4

Representing Information with Bit Combinations • To encode entities (e. g. , symbols), we

Representing Information with Bit Combinations • To encode entities (e. g. , symbols), we need to assign a unique number to each entity (e. g. , social security number). Binary encoding means that we assign a unique combinations of bits to each object. • One bit can be either 0 or 1. Therefore, one bit can represent only two things. • To represent more than two things, we need multiple bits. Two bits can represent four things because there are four combinations of 0 and 1 that can be made from two bits: 00, 01, 10, 11. • If we want to represent more than four things, we need more than two bits. In general, 2 n bits can represent 2 n things because there are 2 n combinations of 0 and 1 that can be made from n bits. • Q: how many bits do we need to encode all the 37 people in the class? 5

Information Representation • Kilobyte approx. 1000 bytes (actually 210 = 1024 bytes) • Megabyte

Information Representation • Kilobyte approx. 1000 bytes (actually 210 = 1024 bytes) • Megabyte approx. 1, 000 bytes (one million) • Gigabyte approx. 1, 000, 000 bytes (one billion) • Terabyte approx. 1 trillion bytes • Petabyte approx. 1 quadrillion bytes 6

Representing Text and Symbols • To represent a text document in digital form, we

Representing Text and Symbols • To represent a text document in digital form, we simply need to be able to represent every possible character that may appear. • There are finite number of characters to represent. So the general approach for representing characters is to list them all and assign each a number (represented in binary). • An encoding scheme is simply a list of characters and the codes used to represent each one. • To represent symbols, computers must use a standard encoding scheme, so that the same symbols have the same codes across different computers. 7

ASCII Encoding Scheme • ASCII stands for American Standard Code for Information Interchange. The

ASCII Encoding Scheme • ASCII stands for American Standard Code for Information Interchange. The ASCII character set originally uses 8 bits to represent each character, allowing for 256 (or 28) unique characters. 8

Representing Text and Symbols • ASCII - the binary code most widely used with

Representing Text and Symbols • ASCII - the binary code most widely used with microcomputers • EBCDIC - used with large computers • Unicode - uses two bytes for each character rather than one 9

The Parity Bit Parity bit - an extra bit attached to the end of

The Parity Bit Parity bit - an extra bit attached to the end of a byte for purposes of checking for accuracy • Even parity - sum of bits must come out even – Ex: given code 0101, the extended code is: 01010 – Ex: given code 01101101, the extended code is: 011011011 • Odd parity - sum of bits must come out odd Even parity scheme 10

Representing Numbers The binary number system • Decimal is base 10: 0, 1, 2,

Representing Numbers The binary number system • Decimal is base 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 • Binary is base 2: 0, 1 • Any decimal number can be converted to binary by doing base conversion from base 10 to base 2. • Any binary number can be converted to decimal by doing base conversion from base 2 to base 10. 11

Number base 10 - decimal The Decimal Number 101 • • 102 101 100’s

Number base 10 - decimal The Decimal Number 101 • • 102 101 100’s 10’s 1 0 1 x 1= x 100 = 1 0 101 12

Number base 2 - binary The Binary Number 101 • • 22 4’s 1

Number base 2 - binary The Binary Number 101 • • 22 4’s 1 x 4 21 2’s 0 20 1’s 1 x 1= x 2 = = 1 0 4 5 13

Binary Conversion - Examples 1 0 1 25 24 23 32 16 8 22

Binary Conversion - Examples 1 0 1 25 24 23 32 16 8 22 21 20 4 2 1 32 + 0 + 8 + 4 + 0 + 1 = 45 14

Binary Conversion - Examples 1 0 1 1 0 8 64 32 16 4

Binary Conversion - Examples 1 0 1 1 0 8 64 32 16 4 2 64 + 0 + 16 + 0 + 4 + 2 + 0 = 86 1 Easier way to remember: Just add the values for each position where there is a 1 128 64 1 0 32 16 8 4 2 1 1 1 0 1 128 + 32 + 16 + 4 + 1 = 181 15

Hexadecimal Representation • Hexadecimal (Hex) = Base 16 – Hex digits: 0, 1, 2,

Hexadecimal Representation • Hexadecimal (Hex) = Base 16 – Hex digits: 0, 1, 2, …, 9, A, B, C, D, E, F Decimal Hex Binary 0 0 0000 8 8 1000 1 1 0001 9 9 1001 2 2 0010 10 A 1010 3 3 0011 11 B 1011 4 4 0100 12 C 1100 5 5 0101 13 D 1101 6 6 0110 14 E 1110 7 7 0111 15 F 1111 16

Hexadecimal Representation • Hex can be used as a short hand for long binary

Hexadecimal Representation • Hex can be used as a short hand for long binary strings – Use one Hex digit to represent every group of 4 bits – Start from the right and an go left grouping 4 bit sequences – Add leading 0’s if the last group has less then 4 bits 1010 1101 0110 1010110 A 1011011 D 6 0101 1011 5 B 17

Hexadecimal Representation • What is Hex 4 C 8 F in binary? 4 C

Hexadecimal Representation • What is Hex 4 C 8 F in binary? 4 C 8 F 0100 1000 1111 18

Representing Images as Bit maps • Image is collection of dots (pixels) • Pixel

Representing Images as Bit maps • Image is collection of dots (pixels) • Pixel = “picture element” – Black & white: one bit per pixel – Color: each pixel represented by combination of green, red, blue in varying intensity, to form all colors. Three bytes per pixel: one byte (8 bits) for each color intensity, 0 -255 value – Usually each byte is represented in Hex § D 4 7 F 59 red (D 4), green (7 F), blue (59) § For example, D 4 is binary 1101 0100 which is decimal value 212 • Bit maps are not efficient – 3 byte/pixel, for 1280 x 1024 pixels = several megabytes – Image cannot be enlarged, since pixels get bigger and image gets grainy or “blocky” –. GIF and. JPEG formats compress images 19

Image Formats • GIF – – – Graphics Interchange Format Developed by Compuserve (ISP)

Image Formats • GIF – – – Graphics Interchange Format Developed by Compuserve (ISP) Stores only 256 colors Loses some picture quality but is simple and fast Common in computer action games • JPEG (JPG) – Joint Photographic Experts Group – Stores differences between adjacent pixels, not absolute values – Uses variable-length data (values take a minimum number of bits to store), uses only 5% of the space of bitmaps 20

Image Formats • Vector Images – – – Pixels are not mapped Equations for

Image Formats • Vector Images – – – Pixels are not mapped Equations for the lines and curves making up the image are stored Image is stored as the instructions for drawing the image Images are easily scaled Modern type fonts are vector images Used in computer aided design (CAD) systems for “blueprint” drawings – Good for three-dimensional drawings – Windows metafile (. wmf) or Visio (. vsd) – Cannot produce photographic images 21