Title: Chapter 3 Data Representation
1Chapter 3Data Representation
2Chapter Goals
Chapter 3
Systems Architecture
- Describe numbering systems and their use in data
representation - Compare and contrast various data representation
methods - Describe how nonnumeric data is represented
- Describe common data structures and their uses
3Data Representation and Processing
Chapter 3
Systems Architecture
- Data can be manipulated in a variety of forms.
- Arabic numerals
- Roman numerals
- Lines or tick marks
- Pictorial characters
- Alphabetic characters
- Sound Waves
4Data Representation and Processing
Chapter 3
Systems Architecture
- To be processed by the brain, the data must be
converted to an appropriate internal format. - Sight
- Smell
- Taste
- Sound
- Skin Sensation
- Electrical Impulses
5Data Representation and Processing
Chapter 3
Systems Architecture
- 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
6Automated Data Processing
Chapter 3
Systems Architecture
- Processing is implemented with electrical
switches. - Switches are combined to form processing
circuits. - For Example A B C
7Automated Data Processing
Chapter 3
Systems Architecture
8Binary Representation of Data
Chapter 3
Systems Architecture
- 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.
9Binary Data Representation
Chapter 3
Systems Architecture
- The symbol used to represent a digit and digit
position within a string determine its value. - For Example
- (5 x 1000) (6 x 100) (8 x 10) 9
- 5,000 600 80 9
5,689
10Binary Data Representation
Chapter 3
Systems Architecture
- 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.
11Binary Data Representation
Chapter 3
Systems Architecture
- 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)
12Binary Data Representation
Chapter 3
Systems Architecture
- The fractional part of a numeric value is
separated from the whole number by a period
(radix point). - For Example 5,689.368
- (3 x .1) (6 x .01) (8 x .001)
- 0.3 0.06 0.008 0.368
13Binary Data Representation
Chapter 3
Systems Architecture
- 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)
14Binary Data Representation
Chapter 3
Systems Architecture
15Binary Data Representation
Chapter 3
Systems Architecture
- 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.
16Binary Data Representation
Chapter 3
Systems Architecture
17Binary Data Representation
Chapter 3
Systems Architecture
18Hexadecimal Notation
Chapter 3
Systems Architecture
- 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.
19Hexadecimal Notation
Chapter 3
Systems Architecture
20Hexadecimal Notation
Chapter 3
Systems Architecture
- The primary advantage of hexadecimal notation, it
its compactness. - Hexadecimal numbers are often used to represent
memory addresses. - Bit strings are usually expressed in binary,
memory address are expressed in hexadecimal.
21Octal Notation
Chapter 3
Systems Architecture
- 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)
22Goals of Computer Data Representation
Chapter 3
Systems Architecture
- Any representation format for numeric data
represents a balance among several factors,
including - Compactness
- Accuracy
- Range
- Ease of manipulation
- Standardization
23Goals of Computer Data Representation
Chapter 3
Systems Architecture
- Compactness
- Compact data representation requires less
storage space. - Compact data representation requires less
expensive processing and storage devices.
24Goals of Computer Data Representation
Chapter 3
Systems Architecture
- 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.
25Goals of Computer Data Representation
Chapter 3
Systems Architecture
- Ease of manipulation
- The efficiency of a processor depends on its
complexity. - Efficient processor circuits perform their
function quickly.
26Goals of Computer Data Representation
Chapter 3
Systems Architecture
- 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.
27CPU Data Types
Chapter 3
Systems Architecture
- Five Primitive Data Types
- Integer
- Excess Notation
- Twos Complement Notation
- Real number
- Floating Point Notation
- Character
- Boolean
- Memory address
28CPU Data Types
Chapter 3
Systems Architecture
- Integers
- An integer is a whole number (For example 3, 5,
6) - Integers can be signed or unsigned
- A signed integer uses one bit to represent the
sign - The sign bit is the high order bit
29CPU Data Types
Chapter 3
Systems Architecture
- 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
30CPU Data Types
Chapter 3
Systems Architecture
31CPU Data Types
Chapter 3
Systems Architecture
- Twos 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
32CPU Data Types
Chapter 3
Systems Architecture
- Twos Complement Notation
- For Example
- Decimal number -710
- Binary representation 01112
- Twos Complement 10002
- Add one 00012
- 10012 (-710)
33CPU Data Types
Chapter 3
Systems Architecture
- Twos 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
34CPU Data Types
Chapter 3
Systems Architecture
- Range and Overflow
- Most modern CPUs use either 32 or 64 bits to
represent a twos complement value - The numeric range of a twos complement value is
(2 n-1) t o(2 n-1-1) - For example the range for a 32 bit number is 2
32-1 to 2 32-1-1 -2 31 to 2 31 - 1
35CPU Data Types
Chapter 3
Systems Architecture
- 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)
36CPU Data Types
Chapter 3
Systems Architecture
- Real Numbers
- A real number can contain both whole and
fractional components - The whole portion appears to the left of the
radix point - The fractional portion appears to the right of
the radix point
37CPU Data Types
Chapter 3
Systems Architecture
- Real Numbers
- For Example
- 18.56 (18 whole portion)
- (.56 fractional portion)
-
38CPU Data Types
Chapter 3
Systems Architecture
39CPU Data Types
Chapter 3
Systems Architecture
- 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
40CPU Data Types
Chapter 3
Systems Architecture
- 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
41CPU Data Types
Chapter 3
Systems Architecture
42CPU Data Types
Chapter 3
Systems Architecture
- Range, Overflow and Underflow
- The number of bits in the string represent the
range of values - Number of bits in the mantissa
- Number of bits in the exponent
43CPU Data Types
Chapter 3
Systems Architecture
44CPU Data Types
Chapter 3
Systems Architecture
- 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.
45CPU Data Types
Chapter 3
Systems Architecture
- 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.
46CPU Data Types
Chapter 3
Systems Architecture
- 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.
47CPU Data Types
Chapter 3
Systems Architecture
- 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.
48CPU Data Types
Chapter 3
Systems Architecture
- Character Data
- Coding Scheme Characteristics
- The specific coding method represents a tradeoff
among compactness, ease of manipulation,
accuracy, range and standardization.
49CPU Data Types
Chapter 3
Systems Architecture
- BCD
- Binary Coded Decimal (BCD)
- Character coding method used by early IBM
mainframe computers. - Characters are encoded as strings of six bits.
- 64 - (26) symbols are represented.
50CPU Data Types
Chapter 3
Systems Architecture
- EBCDIC
- Extended Binary Coded Decimal Interchange
Code - 8 bit coding method used by IBM mainframe
computers. - Characters are encoded as strings of eight bits.
- 256 - (28) symbols are represented.
51CPU Data Types
Chapter 3
Systems Architecture
- ASCII
- American Standard Code of Information
Interchange - Coding method used in data communication that has
been adopted by the United States. - 7-bit and 8-bit formats
- Includes device control codes
52CPU Data Types
Chapter 3
Systems Architecture
53CPU Data Types
Chapter 3
Systems Architecture
54CPU Data Types
Chapter 3
Systems Architecture
- Unicode
- Multilingual character encoding standard
encompassing all of the worlds written
languages. - Characters are coded using 16 bit strings.
- 65,535 (216) characters are represented.
55CPU Data Types
Chapter 3
Systems Architecture
- Boolean Data
- Two data values true and false.
- Data is represented using a single bit.
- Binary 1 can represent true and binary 0 can
represent false.
56CPU Data Types
Chapter 3
Systems Architecture
- Memory Addresses
- Flat memory model
- Memory addresses can be represented using a
single integer. - Segmented memory model
- Memory addresses require multiple integers.
57Data Structures
Chapter 3
Systems Architecture
- A data structure is a related group of
primitive data elements that is organized for
some type of processing. - Data structures are defined and manipulated
within software.
58Data Structures
Chapter 3
Systems Architecture
59Data Structures
Chapter 3
Systems Architecture
- Virtually all data structures make extensive
use of pointers and addresses. - Pointer a data element that contains the
address of another data element. - Address the location of some data element
within a storage device.
60Arrays and Lists
Chapter 3
Systems Architecture
- An array is an ordered list in which each
element can be referenced by an index to its
position. -
61Arrays and Lists
Chapter 3
Systems Architecture
62Arrays and Lists
Chapter 3
Systems Architecture
- Array elements can be stored in contiguous, or
sequential memory locations. - Each character is stored in a single byte of
memory. - Characters are ordered in sequential byte
locations. - Access to individual elements of the array can be
achieved by using the starting address of the
array and the index of the element.
63Arrays and Lists
Chapter 3
Systems Architecture
64Arrays and Linked Lists
Chapter 3
Systems Architecture
- Linked List
- A linked list is a data structure that uses
pointer so list elements can be scattered among
nonsequential storage locations. -
65Arrays and Linked Lists
Chapter 3
Systems Architecture
- Linked List
- In a singly linked list each element occupies
two storage locations - Data value of a list element
- Address of the next element value
-
-
66Arrays and Linked Lists
Chapter 3
Systems Architecture
67Arrays and Lists
Chapter 3
Systems Architecture
68Arrays and Lists
Chapter 3
Systems Architecture
- The procedure to add a new element
- Allocate storage for the new element.
- Copy the pointer from the element preceding the
new element into the pointer field of the new
element. - Write the address of the new element into the
pointer field of the preceding element.
69Arrays and Lists
Chapter 3
Systems Architecture
70Arrays and Lists
Chapter 3
Systems Architecture
- Insertion of an element into a list stored
in contiguous memory -
- Allocate a new storage location at the end of the
list. - For each element past the insertion point, copy
the element value into the next storage location. - Write the new element value in the storage
location at the insertion point.
71Arrays and Lists
Chapter 3
Systems Architecture
72Arrays and Lists
Chapter 3
Systems Architecture
- A doubly linked list
- Each element has two pointers
- One pointer points to the next element in the
list - One pointer points to the previous element in the
list
73Arrays and Lists
Chapter 3
Systems Architecture
- Doubly linked list
- Advantage
- The list can be traversed in any order
- Disadvantage
- More pointers must be updated each time an
element is inserted or deleted - More storage locations are required to hold the
extra set of pointers
74Arrays and Lists
Chapter 3
Systems Architecture
75Records and Files
Chapter 3
Systems Architecture
- A record is a data structure composed of other
data structures or primitive data elements. - Records are used as a unit of input and output to
files or databases.
76Records and Files
Chapter 3
Systems Architecture
77Records and Files
Chapter 3
Systems Architecture
- A sequence of records on secondary storage is
called a file. - A sequence of records stored within main memory
is called a table. - Sequential files suffer the same problems as
contiguous arrays when inserting and deleting
records. - To eliminate this problem, linked lists and
indexed files are used.
78Records and Files
Chapter 3
Systems Architecture
79Classes and Objects
Chapter 3
Systems Architecture
- An alternative view of computer and software
behavior has been developed. - This view involves classes and objects.
- A class is a data structure that contains both
data elements and programs that manipulate that
data. - The programs in a class are methods.
- An object is one instance or variable of the
class.
80Classes and Objects
Chapter 3
Systems Architecture
81Summary
Chapter 3
Systems Architecture
- To be processed by any device, data must be
converted from its native format into a form
suitable for the processing device. - All data, including nonnumeric data, are
represented within a modern computer system as
strings of binary digits, or bits. - Each bit string has a specific data format and
coding method.
82Summary
Chapter 3
Systems Architecture
- Numeric data is stored using integer, real
number, and floating point formats. - Characters are converted to numbers by means of a
coding table. - Boolean vales can have only two values, true and
false. - Programs often need to define and manipulate data
in larger and more complex units than primitive
CPU data types.