1 / 50

Chapter 2

Chapter 2. Data Representation. O BJECTIVES. Visualize how data are stored inside a computer. Understand the differences between text, numbers, images, video, and audio. Work with hexadecimal and octal notations. Define data types. After reading this chapter, the reader should be able to:.

Download Presentation

Chapter 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 2 Data Representation

  2. OBJECTIVES Visualize how data are stored inside a computer. Understand the differences between text, numbers, images,video, and audio. Work with hexadecimal and octal notations. Define data types. After reading this chapter, the reader should be able to:

  3. 2.1 DATA TYPES

  4. Figure 2-1 Different types of data

  5. Uses of Computer in Various Program • Engineering: to process numbers, do arithmetic, solve algebraic, trigonometric, equation • Word processing: process text, justify, move, delete • Image processing: to manipulate images, create, shrink, expand, rotate • Audio: play music, record voice • Video: Play movie, create special effects

  6. Note: The computer industry uses the term“multimedia” to define information that contains numbers, text, images, audio, and video.

  7. 2.2 DATA INSIDE THE COMPUTER

  8. Question? • How do you handle all these data types? • Do you have different computers process different types of data? • Do you have a category of computers that processes only numbers? • Do you have a category of computers that processes only text?

  9. Solution • Solution of different computers to process different types of data is neither economical nor practical because data is usually a mixture of types. • Most efficient solution: to use a uniform representation. All data from outside a computer are transformed into this uniform representation when stored in a computer and then transformed back when leaving the computer. • It is called a bit pattern

  10. Figure 2-2 Bit pattern • To represent different types of data • Or called a sequence, a string of bits • Figure above shows a bit pattern made of 16 bits • If you need to store a bit pattern made of 16 bits, you need 16 electronic switches. • If need to store 1000 bit patterns, each 16 bits, you need 16 000 switches.

  11. How does computer memory know what type of data a stored bit pattern represent? • It does not. • Computer memory just stores the data as bit patterns. • It is the responsibility of input/output devices or programs to interpret a bit pattern as a number, text or some other type of data. • Data are coded when they enter a computer and decoded when they are presented to the user.

  12. Figure 2-3 Examples of bit patterns From input devices To output devices Store data

  13. BYTE • A bit pattern of lenghth 8 is called a byte • This term also has been used to measure the size of memory or other storage devices. • Example: a computer memory that can store 8 million bits of information is said to have a memory of 1 million bytes.

  14. 2.3 REPRESENTING DATA

  15. Figure 2-4 Representing symbols using bit patterns

  16. Table 2.1 Number of symbols and bit pattern length depends on logarithmic. It is not linear Number of Symbols--------------------- 2 4 8 16 … 128 256 … 65,536 Bit Pattern Length--------------------- 1 2 3 4 … 7 8 … 16

  17. Examples 1 • Number of Symbols 4 00 01 10 11 • Bit Pattern Length 2

  18. Examples 2 • Number of Symbols 8 000 001 010 011 100 101 110 111 • Bit Pattern Length 3

  19. CODES • Code = Different sets of bit pattern designed to represent text symbols • Coding = Process of representing symbols

  20. ASCII • American National Standards Institute (ANSI) develops American Standard Code for Information Interchange • Used 7 bits for each symbol

  21. Features of ASCII • ASCII uses a 7-bit pattern ranging from 0000000 to 1111111 • 0000000 represent the null character (lack of character) • 1111111 represent the delete character • 31 control (nonprintable) characters • Numeric characters (0 to 9) are coded before letters • Several special printable characters • UPPERCASE A..Z) come before lowercase (a..z) • UPPERCASE and lowercase distinguished by only 1 bit. Eg: A = 1000001, a = 1100001; difference in the 6th bit from right. • Six special characters between UPPER and lowercase letters

  22. Figure 2-5 Representation of the word “BYTE” in ASCII code

  23. EXTENDED ASCII • To make the size of each pattern 1 byte (8 bits) • Augmented with an extra 0 at the left • Start 00000000 • Ended 01111111

  24. EBCDIC • Extended Binary Coded Decimal Interchange Code • Used 8-bit pattern • Represent up to 256 symbols • Not used in any computers other than IBM

  25. Unicode • Designed by coalition of hardware and software manufacturers • Uses 16 bits • Represent up to 650536 (216) symbols • Some code used for graphical and special symbols • Used by JavaTM language to represent characters. • Used by Microsoft Windows the variation of the first 256 characters

  26. ISO • International Organization for Standardization • Designed code using 32-bit patterns • Represent up to 4 294 967 296 (232) symbols

  27. NUMBERS • Represent number using binary system in a computer

  28. IMAGES • Represent in a computer by two methods • Bitmap graphic • Vector graphic

  29. Bitmap Graphic • Image is divided into a matrix of pixels (picture elements) • Each pixel is a small dot • Size of pixel = resolution • To represent color images,each colored pixel is decomposed into three color; RED, GREEN, BLUE (RGB) • For better representation of image, more memory is needed to store the image

  30. Figure 2-7 Bitmap graphic method of a black-and-white image; used 1 bit pattern

  31. Each pixel has three bit patterns • one to represent the intensity of the red color • one to represent the intensity of the green color • one to represent the intensity of the blue color

  32. Figure 2-8 Representation of color pixels

  33. Vector graphic • Does not store the bit pattern • In bitmap, if want to rescale the image, you must change the size of pixel • Vector graphic decomposed into a combination of curve and lines

  34. AUDIO • Represent sound and music • The idea is to convert analog audio (continuous) to digital data (discrete) and used bits pattern to store

  35. Figure 2-9 Audio representation

  36. VIDEO • Represent of images (called frames) in time • Movie = series of frames shown one after another to create the illusiion of motion • Each images or frame is changed to a set of bit patterns and stored • In MPEG files

  37. 2.4 HEXADECIMAL NOTATION

  38. Note: A 4-bit pattern can be representedby a hexadecimal digit,and vice versa.

  39. Table 2.2 Hexadecimal digits Bit Pattern------------ 0000 0001 0010 0011 0100 0101 0110 0111 Hex Digit------------ 0 1 2 3 4 5 6 7 Bit Pattern------------ 1000 1001 1010 1011 1100 1101 1110 1111 Hex Digit------------ 8 9 A B C D E F

  40. Figure 2-10 Binary to hexadecimal and hexadecimal to binary transformation

  41. Example 1 Show the hexadecimal equivalent of the bit pattern 1100 1110 0010. Solution Each group of 4 bits is translated to one hexadecimal digit. The equivalent is xCE2.

  42. Example 2 Show the hexadecimal equivalent of the bit pattern 0011100010. Solution Divide the bit pattern into 4-bit groups (from the right). In this case, add two extra 0s at the left to make the number of bits divisible by 4. So you have 000011100010, which is translated to x0E2.

  43. Example 3 What is the bit pattern for x24C? Solution Write each hexadecimal digit as its equivalent bit pattern to get001001001100.

  44. 2.5 OCTAL NOTATION

  45. Note: A 3-bit pattern can be representedby an octal digit, and vice versa.

  46. Table 2.3 Octal digits Bit Pattern------------ 000 001 010 011 Oct Digit------------ 0 1 2 3 Bit Pattern------------ 100 101 110 111 Oct Digit------------ 4 5 6 7

  47. Figure 2-11 Binary to octal and octal to binary transformation

  48. Example 4 Show the octal equivalent of the bit pattern101110010. Solution Each group of 3 bits is translated to one octal digit. The equivalent is 0562,o562, or 5628.

  49. Example 5 Show the octal equivalent of the bit pattern 1100010. Solution Divide the bit pattern into 3-bit groups (from the right). In this case, add two extra 0s at the left to make the number of bits divisible by 3. So you have 001100010, which is translated to 1428.

  50. Example 6 What is the bit pattern for 248? Solution Write each octal digit as its equivalent bit pattern to get 010100.

More Related