chapter 3 data representation. chapter goals describe numbering systems and their use in data...
Post on 20-Dec-2015
243 views
TRANSCRIPT
![Page 1: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/1.jpg)
Chapter 3
Data Representation
![Page 2: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/2.jpg)
Chapter goals Describe numbering systems and their use in
data representation Compare and contrast various data
representation methods Describe how nonnumeric data is
represented
![Page 3: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/3.jpg)
Data representation Humans have many symbolic
forms to represent information Alphabet, numbers, pictograms
Computer can only represent information with electrical signals Is a circuit on or off?
![Page 4: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/4.jpg)
Computers, numbers, and binary data Computers only use on/off signals
to represent information These signals can only represent
numeric data Even character based data is
represented as a number
![Page 5: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/5.jpg)
Why binary data? Electricity has two states, on and
off On = 1 Off = 0
Binary numbers only have 0s and 1s
Data is stored as collections of binary numbers
![Page 6: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/6.jpg)
Binary numbers are “computer friendly” Binary numbers are signals that
can easily be transported Binary numbers can be easily
processed (transformed) by two-state electrical devices that are easy to design and fabricate These devices (and/or gates, adders)
are strung together like an assembly line to carry out a function
![Page 7: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/7.jpg)
Logic gates
![Page 8: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/8.jpg)
Boolean algebra System developed by George
Boole (19th century mathematician) that can determine if two values are:
Equal, not equal, less than, greater than, etc.
Boolean algebra allows the CPU to carry out binary arithmetic (see White p.36-37)
![Page 9: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/9.jpg)
Binary numbers Can be combined into a positional
numbering system Base for decimal numbers is 10,
base for binary numbers is 2 Each position to the left is an
increasing factor of 2
![Page 10: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/10.jpg)
Terminology for number systems Base is also referred to as the radix Binary numbers have a radix of 2 Decimal numbers have a radix of 10 Radix point separates whole values
from fractional values Decimal point is a kind of radix point
![Page 11: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/11.jpg)
Base 2 positional example
![Page 12: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/12.jpg)
Numbering systems Higher base (radix) means fewer
positions are needed to represent a number
Base 2 needs many more positions than base 10
Base 16 (hexidecimal) is often used to represent binary numbers
![Page 13: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/13.jpg)
Computers & binary numbers Each digit of a binary number is
called a bit Bit string – group of digits that
describes a single value
![Page 14: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/14.jpg)
Bit strings Left most bit (most significant bit) called
high order bit Right most bit (least significant bit)
called low order bit 8 bits make a byte Programming
languages/spreadsheets/etc. automatically translate from base 10 to base 2 and back again
![Page 15: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/15.jpg)
Hexadecimal notation Base or radix is 16 More compact than binary Symbols used are 0-9, A-F One hexadecimal position
corresponds to 4 bits Used to designate memory
locations, colors (html & VB)
![Page 16: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/16.jpg)
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
![Page 17: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/17.jpg)
Balancing objectives Compactness and range are
inversely related: the more compact, the smaller the range
Accuracy increases with # of bits used, especially with real numbers: example, 1/3, or 0.33333333 (non-terminating fraction)
![Page 18: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/18.jpg)
Other objectives Does information format make it
easier for processor to perform operations?
Is data in a standard format, allowing simple transfer between computers?
![Page 19: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/19.jpg)
CPU standard data types Integer Real number Character Boolean Memory address
![Page 20: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/20.jpg)
Integer data types Unsigned – assumed to be positive Signed – uses one bit (usually high
order bit) to indicate sign 0 is positive, 1 is negative
![Page 21: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/21.jpg)
Representing negative integers Excess notation and twos
complement Allow subtraction to be carried out
as addition Number is converted to its complement 1 is added to the result When added to another binary number,
carry bit is ignored
![Page 22: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/22.jpg)
Range and overflow Most CPUs use a fixed width of 32
or 64 bits to represent an integer For small numbers format is
padded with leading zeros Machine processes fixed width
information more easily than variable width
![Page 23: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/23.jpg)
Integer overflow If number is too big for fixed width
integer format CPU throws an overflow error
Integer format width is tradeoff between overflow and wasted space (padded zeros)
CPU often use double precision data types for arithmetic operations
![Page 24: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/24.jpg)
Representing real numbers More complicated problem than
storing integers Real numbers contain whole &
fractional components How to represent both parts
together in one format?
![Page 25: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/25.jpg)
Fixed format for real numbers
![Page 26: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/26.jpg)
Floating point notation Any real number can be re-written
using floating point (scientific notation)
12.555 becomes 1.2555 X 10¹ Format stores 12555 (mantissa), 1
(exponent), and sign (+) -143.99 becomes 1.4399 X 102
Format stores 14399 (mantissa), 2 (exponent), and sign (-)
![Page 27: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/27.jpg)
IEEE floating point format for real numbers
![Page 28: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/28.jpg)
Floating point range Number of bits in floating point
format limit range of exponent, mantissa
Overflow (too large a number) always occurs in the exponent
Underflow (too small a number, i.e. negative exponent does not fit)
![Page 29: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/29.jpg)
Range for mantissa Number of bits for mantissa limit the
number of significant digits stored for a real number
23 bits allows for approx. 7 decimal places of precision
Mantissa is stored using truncation (information that does not fit is discarded) Does not throw an overflow condition
![Page 30: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/30.jpg)
Processing complexity General rule is floating point
operations (+, -, *, etc.) take CPU twice as long as integers (binary)
Floating Point Operations Per Second (FLOPS) is a measure of processor speed
![Page 31: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/31.jpg)
Character data Alphabetic letters (upper & lower
case), numerals, punctuation marks, special symbols are called characters
Variable of type character contain only one symbol
Sequence of symbols forming words, sentences, etc. called a string
![Page 32: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/32.jpg)
How computers store characters Character data cannot be directly
processed by a computer Must be translated into a number Characters are converted into
numbers using a table of correspondences between a character and a bit string
![Page 33: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/33.jpg)
Design issues for character coding schemes Table must be publicly available
and all users must use the same table
Coding scheme is a tradeoff among compactness, ease of manipulation, accuracy, range, & standardization
![Page 34: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/34.jpg)
Examples of character coding schemes BCD and EBCIDIC – older IBM
mainframe computers ASCII – PCs Unicode – larger format allows for
expanded and international alphabets (Java and internet applications)
![Page 35: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/35.jpg)
ASCII coding scheme 7 bit format allows for parity bit
(used to check for errors over transmission lines)
Has unique codes for all uppercase & lowercase letters, numbers, other printable characters
Also includes codes for device control
![Page 36: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/36.jpg)
Device control In many applications that handle
text, formatting & commands to a device are included in the same stream of data as the text Examples: word processors (reveal
codes), HTML tags Examples: CR (carriage return),
tab, form feed
![Page 37: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/37.jpg)
Limitations to ASCII Not robust enough to represent
multiple languages and symbols 7 bit format allows for 128 unique
codes, some languages have thousands of symbols
Unicode (16 bit) has 65,536 entries
![Page 38: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/38.jpg)
Boolean data Data types has two values, true
and false Can be stored with one bit The results of many CPU
operations (comparisons) generate a Boolean value stored in a register
![Page 39: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/39.jpg)
Memory addresses Primary storage is a series of
contiguous bytes CPU must be able to access
sections of memory directly Sections of memory are accessed
by their address (location)
![Page 40: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/40.jpg)
Formats for memory addresses Flat memory model – memory starts at
address 0, goes to maximum capacity – 1 Simple integers used to store address
Segmented memory model Memory is divided into equal sized segments
called pages Address has two parts
00FA:0034 number for page, and location within page
![Page 41: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/41.jpg)
Data structures These five primitive types are quite
limited for representing real world data Words, sentences Dates Data base tables
More complex data structures constructed from these five primitive types
![Page 42: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/42.jpg)
Data Structures
![Page 43: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/43.jpg)
Data Structures
![Page 44: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/44.jpg)
Data Structures
![Page 45: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/45.jpg)
Data Structures
![Page 46: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/46.jpg)
Data Structures
![Page 47: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/47.jpg)
Data Structures
![Page 48: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/48.jpg)
Data Structures
![Page 49: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/49.jpg)
Data Structures
![Page 50: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/50.jpg)
Data Structures
![Page 51: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/51.jpg)
Data Structures
![Page 52: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/52.jpg)
Data Structures
![Page 53: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/53.jpg)
Chapter summary 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.
![Page 54: Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation](https://reader035.vdocuments.site/reader035/viewer/2022062313/56649d4b5503460f94a2910a/html5/thumbnails/54.jpg)
Summary (cont.) 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.