1 / 79

Chapter 3 Data Representation

Chapter 3 Data Representation. Chapter Goals. Numbering systems and their use in data representation Compare & contrast various data representation methods Describe how nonnumeric data is represented Describe common data structures and their uses. Data Representation and Processing.

cara
Download Presentation

Chapter 3 Data Representation

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 3Data Representation

  2. Chapter Goals • Numbering systems and their use in data representation • Compare & contrast various data representation methods • Describe how nonnumeric data is represented • Describe common data structures and their uses INFO 225: Chapter 3

  3. Data Representation and Processing Data can be manipulated in a variety of forms: • Arabic numerals • Roman numerals • Lines or tick marks • Pictorial characters • Alphabetic characters • Sound Waves INFO 225: Chapter 3

  4. Data Representation and Processing To be processed by the brain, the data must be converted to an appropriate internal format. • Sight • Smell • Taste • Sound • Skin Sensation • Electrical Impulses INFO 225: Chapter 3

  5. Data Representation and Processing Data and information processors must be able to: • Recognize external data and convert it to an appropriate internal format • Store and retrieve data internally • Transport data among internal storage and processing components INFO 225: Chapter 3

  6. Automated Data Processing • Processing is implemented with electrical switches. • Switches are combined to form processing circuits. For Example: To add two numbers A & B A + B = C we need the processing circuit: INFO 225: Chapter 3

  7. Automated Data Processing Figure 3-1: Two electrical Inputs on the left flow through processing circuitry that generates their sum on the right. INFO 225: Chapter 3

  8. Binary Representation of Data • Computers represent data using binary numbers. • Binary numbers correspond directly with values in Boolean logic. • Computers combine multiple digits to form a single data value to represent large numbers. INFO 225: Chapter 3

  9. Binary Data Representation The symbol used to represent a digit and digit position within a string determines its value. For Example: (5 x 1000) + (6 x 100) + (8 x 10) + 9 = 5,000 + 600 + 80 + 9 = 5,689 INFO 225: Chapter 3

  10. Binary Data Representation The multiplier that describes the difference between one position and the next is the base (radix). • The base (radix) of a decimal number system is 10. • The base (radix) of a binary number system is 2. INFO 225: Chapter 3

  11. Binary Data Representation The number of characters in the number system is equal to the base of the number system. • There are 10 characters in the decimal number system: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) • There are 2 characters in the binary number system: (0, 1) INFO 225: Chapter 3

  12. Binary Data Representation The fractional part of a numeric value is separated from the whole number by a “period” (.) “called radix point”. For Example: 5,689.368 (3 x .1) + (6 x .01) + (8 x .001) = (3 x10-1) + (6x10-2) + (8x10-3) = 0.3 + 0.06 + 0.008 = 0.368 INFO 225: Chapter 3

  13. Binary Data Representation In the binary numbering system: • The first position to the right of the radix point represents halves ( 2-1) • The second position to the right of the radix point represents quarters (2-2) • The third position to the right of the radix point represents eights (2-3) INFO 225: Chapter 3

  14. Binary Data Presentation Table 3-1: Binary and decimal notations for the values 0 through 10 INFO 225: Chapter 3

  15. Binary Data Representation You can convert a binary number to its decimal equivalent by multiplying the value of each position by the decimal weight of that position, then summing the results. 1010 Binary Number 1x23+0x22+1x21+0x20 (digit x baseposition+…) 1x8+0x4+1x2+0x1 8+0+2+0 10 INFO 225: Chapter 3

  16. Binary Data Representation INFO 225: Chapter 3

  17. Binary Data Representation Computing the decimal equivalent of a binary number INFO 225: Chapter 3

  18. Hexadecimal Notation • The base(radix) of a hexadecimal number system is 16. • There are 16 characters in the hexadecimal number system. • There are only 10 characters in the Arabic number system that can be used to represent some of the 16 characters in the hexadecimal number system. • The letters A, B, C, D, E, F are used to represent the last 6 characters in the hexadecimal number system. INFO 225: Chapter 3

  19. Hexadecimal Notation Table 3-3 Hexadecimal and decimal values INFO 225: Chapter 3

  20. Hexadecimal Notation • The primary advantage of hexadecimal notation, is its compactness. • Hexadecimal numbers are often used to represent memory addresses. • Bit strings are usually expressed in binary, memory address are expressed in hexadecimal. INFO 225: Chapter 3

  21. Octal Notation • Some operating systems and machine language programs use octal notation. • The base(radix) of an Octal number system is 8. • There are 8 characters in the octal number system. (0, 1, 2, 3, 4, 5, 6, 7) • Octal is a third of corresponding binary notation: • (7)8=(111)2 • Octal is double the length of hex: • (F)16=(17)8=(1111)2 INFO 225: Chapter 3

  22. Binary vs Hex INFO 225: Chapter 3

  23. Decimal, Binary, Hex, Octal • Decimal= 1023 = (1x103)+(0x102)+(2x101)+(3x100) • Binary = 0000 0011 1111 1111= (0x215+ 0x214 + 0x213 +…+1x23+1x22+1x21+1x20) • Octal = 1356 = (1x83)+(3x82)+(5x81)+(6x80) • Hex = 03FF = (0x163)+(3x162)+(Fx161)+(Fx160) INFO 225: Chapter 3

  24. LSB MSB INFO 225: Chapter 3

  25. Decimal Number is 1023 LSB MSB (1023) At Base 10 = (1777) at base 8 = (1x83)+(7x82)+(7x81)+(7x80) INFO 225: Chapter 3

  26. Hex = 03FF = (0x163) + (3x162) + (Fx161) + (Fx160) LSB MSB (1023) At Base 10 = (03FF) at base16 = (0x163)+(3x162)+(Fx161)+(Fx160) INFO 225: Chapter 3

  27. Goals of Computer Data Representation Any representation format for numeric data represents a balance among several factors, including: • Compactness • Accuracy • Range • Ease of manipulation • Standardization INFO 225: Chapter 3

  28. Goals of Computer Data Representation Compactness: Compact data representation requires: • less storage space • less expensive processing • less expensive storage devices. INFO 225: Chapter 3

  29. Goals of Computer Data Representation Accuracy: • The accuracy of representation increases with the number of data bits used. • Routine calculations can generate quantities that are either too large or too small to be stored within finite circuitry. INFO 225: Chapter 3

  30. Goals of Computer Data Representation Ease of manipulation: • The efficiency of a processor depends on its complexity. • Efficient processor circuits perform their function quickly. INFO 225: Chapter 3

  31. Goals of Computer Data Representation Standardization: • Data formats must be suitable for a wide variety of devices and computer systems. • Various organizations have created standard data encoding methods for communication among computer systems and their components. INFO 225: Chapter 3

  32. CPU Data Types Five Primitive Data Types: • Integer • Excess Notation • Two’s Complement Notation • Real number • Floating Point Notation • Character • Boolean • Memory address INFO 225: Chapter 3

  33. CPU Data Types Integers: • An integer is a whole number (e.g., 3, 5, 6) • Integers can be signed (+12, -8, etc.) or unsigned (20, 31, etc.) • A signed integer uses one bit to represent the sign • The sign bit is the high order bit (Leftmost or Most Significant Bit-MSB) INFO 225: Chapter 3

  34. CPU Data Types Excess Notation: • Excess notation is used to represent signed integers • A fixed number of bits is used to represent the number • The leftmost digit represents the sign • The leftmost digit is 1 for positive values • The leftmost digit is 0 for negative values INFO 225: Chapter 3

  35. CPU Data Types INFO 225: Chapter 3

  36. CPU Data Types Two’s Complement Notation: • Nonnegative integer values are represented as ordinary binary numbers • Negative integer values are represented using – (Complement of positive value + 1) • The complement of a number is formed by changing all 1 bits to 0 and all 0 bits to 1 INFO 225: Chapter 3

  37. CPU Data Types Two’s Complement Notation: For Example: Decimal number:-710 Binary representation: 01112 One’s Complement: 10002 Add one: + 00012 Two’s Complement: 10012 = (-710) INFO 225: Chapter 3

  38. CPU Data Types Two’s Complement Notation: • The leftmost bit represents the sign • A fixed number of bit positions are used • Only two logic circuits are required to perform addition on single-bit values • Subtraction can be performed as addition of a negative value INFO 225: Chapter 3

  39. CPU Data Types Range and Overflow: • Most modern CPUs use either 32 or 64 bits to represent a two’s complement value • The numeric range of a two’s complement value is –(2 n-1) to (2 n-1-1) For example: The range for a 32 bit number is –2 32-1 to 2 32-1-1 OR -2 31 = -2,147,483,648 to 2 31 – 1 = 2,147,483,647 INFO 225: Chapter 3

  40. CPU Data Types Range and Overflow: • If data is too large to store in the 32 or 64 bits, then overflow occurs • Overflow is treated as an error by the CPU • To avoid overflow some computers and programming languages define additional data types as double precision (long integer) INFO 225: Chapter 3

  41. CPU Data Types • Real Numbers: • A real number can contain both whole and fractional components • The whole portion appears to the left of the radix point (321.43) • The fractional portion appears to the right of the radix point (321.43) Real Numbers: For Example: 18.56 (Real Number) (18 whole portion) (.56 fractional portion) 16-bit 216-1 = 65,535 15-bit 0.000030517578125 Figure 3-3: A simple way to represent a real number within computer circuitry:32 bit storage format for real numbers using a fixed radix point Example: Decimal: 18.0 / 4.0 = 4.5 Binary: 10010 / 100 = 100.1 INFO 225: Chapter 3

  42. CPU Data Types Floating point notions are like scientific notation except 2 is the base rather than 10. Floating Point Notation: • Floating point notation is used to represent very small numbers and very large numbers • Values can either be very large or very small, but not both at the same time 0.0000000013526473 1352647300000000.0 13,526,473x10-16 13,526,473x108 Value = mantissa x 10 exponent Value = mantissa x 2 exponent

  43. CPU Data Types Floating Point Notation: • The exponent attached to the base can be interpreted as the number and the direction of positional moves of the radix point • Negative exponents indicate a movement to the left, and positive exponents indicate movement to the right Fig 3-4: Convention of Scientific Notation to Decimal Notation INFO 225: Chapter 3

  44. Range, Overflow and Underflow: • Overflow occurs when the exponent is larger than the allocated space. • Underflow occurs when a negative exponent is too large in absolute value to fit within the bits allocated to store it. CPU Data Types Range, Overflow and Underflow: • The number of bits in the string represent the range of values • Number of bits in the mantissa (digits of the real number) • Number of bits in the exponent (position of radix point) 23-bit 8-bit Figure 3-5: IEEE 32 bit floating point format IEEE standard 754 defines 32-bit floating point IEEE standard 854 defines 64-bit floating point Largest Absolute Number:1.11111111111111111111111x211111111 INFO 225: Chapter 3

  45. CPU Data Types • Precision: accuracy is reduced as the number of digits available to store the mantissa is reduced. • Truncation: if the number of digits in the mantissa is larger than the allocated space, the number of digits in the mantissa is truncated. INFO 225: Chapter 3

  46. CPU Data Types Character Data: • An individual symbol is a character. • Characters grouped together form a string. • Character data can only be represented in the computer system using a coding scheme. INFO 225: Chapter 3

  47. CPU Data Types Character Data: Coding Scheme Characteristics: • All users must use the same table of correspondence. • The values used to represent the data must be capable of being encoded, transmitted, and decoded. INFO 225: Chapter 3

  48. CPU Data Types Character Data: Coding Scheme Characteristics: The specific coding method represents a tradeoff among compactness, ease of manipulation, accuracy, range, and standardization. INFO 225: Chapter 3

  49. CPU Data Types Binary Coded Decimal (BCD): • Character coding method used by early IBM mainframe computers. • Characters are encoded as strings of six bits. • (26) = 64 symbols are represented. INFO 225: Chapter 3

  50. CPU Data Types Extended Binary Coded Decimal Interchange Code (EBCBIC): • 8 bit coding method used by IBM mainframe computers. • Characters are encoded as strings of eight bits. • (28) = 256 symbols are represented. INFO 225: Chapter 3

More Related