Range Overflow

advertisement
Chapter 3
Range Overflow
• Fixed length of bits to hold numeric data
• Can hold a maximum positive number
(unsigned)
16 Bits
X
X X
X X X X X X X X X X X X X
16384
4096 1024 256 128 64 32 16 8 4 2 1
32768
8192 2048 512
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
-----------6553510
Cis303a_chapt03-2a.ppt
Range Overflow
• Fixed length of bits to hold numeric data
• Can hold a maximum positive and negative
number (signed)
16 Bits
X
X X
X X X X X X X X X X X X X
16384
4096 1024 256 128 64 32 16 8 4 2 1
32768
8192 2048 512
Sign bit – not
used to hold
numeric data
Cis303a_chapt03-2a.ppt
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
-----------+/- 3276710
Range Overflow
• Numeric range of an unsigned integer
(no sign bit – all bits used for numeric data)
2n-1
n-1
= number of bits
216-1 = 215
(16 bits – 0 through 15)
X
X X
X X X X X X X X X X X X X
16384
4096 1024 256 128 64 32 16 8 4 2 1
32768
8192 2048 512
215
214 213 212 211 210 29
Cis303a_chapt03-2a.ppt
28 2 7 26
32768
16384
8192
4096
2048
1024
512
256
128
64
32
16
8
4
2
1
-----------6553510
25
24 23 22 21 20
Real Numbers
• Contains Whole number and fraction
• Fraction to the right of the radix point
(decimal position)
100102 / 1002= 100.12
Radix
(decimal point)
1001
100
Cis303a_chapt03-2a.ppt
100100
0
01
0
100
100
000
= 100.12
Real Numbers
• Contains Whole number and fraction
• Fraction to the right of the radix point
(decimal position)
X
X X
X X X X X X X X X X X X X
16384
4096 1024 256 128 64 32 16 8 4 2 1
32768
8192 2048 512
4.510
10 0.1
SXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXX
(Page 67)
2-1
2-2
2-3
2-4
Cis303a_chapt03-2a.ppt
= ½ = .5
= ¼ = .25
= 1/8 = .125
= 1/16 = .0625
Floating Point
(Page 77-79)
• Contains Whole number and fraction
• Radix is movable to accommodate
extremely large positive or negative numbers
• Radix is not fixed
• Negative exponent – radix moves to the left
the exponent amount
2-5
xxxxxxxxx.
• Positive exponent – radix moves to the
right the exponent amount
25
x.xxxxxxxx
Sign Exponent Mantissa
SEEEEEEEMMMMMMMMM
Cis303a_chapt03-2a.ppt
Character Data
(Page 81)
• Alphabetic letters
• Numerals
• Punctuation
• Special Purpose ($,%,&,# ETC.)
String: a grouping of character data
Early Computers
• Binary Coded Decimal (BCD)
• 6 bits (Octal)
• Limited character range
• Limited memory
• Slow processors
Cis303a_chapt03-2a.ppt
Character Data
(Table Page 83)
Modern computers
• Extended Binary Coded Decimal
Interchange Code (EBCDIC)
• 8 bits (Hexadecimal)
• Mainframes
American Standard Code for Information
Interchange (ASCII)
• Data hardware communications
Printers, displays (monitors)
• 8 bit format
• Parity checking – one bit
• Data – 7 bits
• Data communications
• Displayable characters (A-Z, 0-9 etc.)
• Device control characters
• Page eject
• Load/unload CD
Cis303a_chapt03-2a.ppt
Device Control
(Page 84)
Serial Transmission:
• Book: Transmission of one character at a time
over a single wire
• Transmission of one or more bytes of data
transmitted one bit after another
• Data is placed in a buffer in the receiving
device
• Data is acted upon (control character
or information data) when the buffer is
filled or an Escape character is received
(Table 3-6 page 85)
Parallel Transmission:
•Transmission of one or more bytes of data
transmitted at the same time along multiple
wires
• Data is placed in a buffer in the receiving
device
• Data is acted upon (control character
or information data) when the buffer is
filled or an Escape character is received
Cis303a_chapt03-2a.ppt
Unicode
(Page 87)
• An attempt to commonize data formation
• Includes the ASCII character set
• 16 bit – allows up to 65,536 separate
characters/commands
• International Standards Organization (ISO)
• Can handle many languages other than
English
Boolean Data
(Page 88)
• Contains on one of two possible states
• True
• False
• Used with programmatic logic
(IF statements)
• Decision statements
• Pack data
• Store boolean results (single bits) into
bytes
Cis303a_chapt03-2a.ppt
Memory Addresses
(Page 89)
• Contiguous bytes of storage
• Each byte is addressable (accessible)
• Non negative address numbers
• An attempt to commonize data formation
• Flat Memory Model
• Beginning byte is 0 and continues
sequentially until the last byte of
memory
• Segmented Memory Model
• Memory divided into sections (pages)
• Each page has separate address
• Each byte in a page has an address
• 9Includes the ASCII character set
• 16 bit – allows up to 65,536 separate
characters/commands
• International Standards Organization (ISO)
• Can handle many languages other than
English
Cis303a_chapt03-2a.ppt
Memory Addresses
• Flat Memory Model
• Beginning byte is 0 and continues sequentially
until the last byte of memory
0
1
Address
Register
2
3
4
5
6
7
10
11
12
13
Cis303a_chapt03-2a.ppt
Memory Addresses
•Segmented Memory Model
• Memory divided into sections (pages)
• Each page has separate address
• Each byte in a page has an address
• 9Includes the ASCII character set
Address
Register
0
1
Segment
2
3
4
Segment
5
6
7
10
Segment
11
12
13
Cis303a_chapt03-2a.ppt
Data Structures
• Primitive Data types
• Data types of the CPU
• Binary strings of bits
• Programming Data types
• Character
• Numeric
• Data Structure
• A related group of primitive data
elements that is organized for some type
of common processing (page 91)
• Groups of Primitive Data Types
assembled by the programmer into
usable data strings (alpha or numeric)
• Character strings, numbers, arrays,
records, files
• System software provides application
services to manipulate commonly used Data
Structures (i.e. drivers, interfaces)
(page 92)
Cis303a_chapt03-2a.ppt
Pointers
(Page 93)
• A data element that contains the address
(points to) another data element (data or and
address)
• Disk read/writes
• Blocks (i.e. 512k block)
• Address ‘points’ to the beginning of the
block
• The driver knows how much data to
gather for the read/write
Arrays and Lists
(Page 93)
• List: unordered set of related data
• Array: an ordered set of related data
• Each element can be referenced
specifically for it’s contents
Cis303a_chapt03-2a.ppt
Arrays and Lists
• List: unordered set of related data
• Array: an ordered set of related data
• Each element can be referenced
specifically for it’s contents
List
(unordered)
Array
(ordered)
1.00
1.00
8.00
2.00
10.00
3.00
4.00
4.00
5.00
5.00
2.00
6.00
9.00
7.00
3.00
8.00
6.00
9.00
7.00
10.00
Purchase a 5 hamburgers: got to
5th element in the array
Cis303a_chapt03-2a.ppt
Linked Lists
(Page 95)
• A data structure that uses pointers
• Element may be scattered – do not have to
be contiguous
6.00
1.00
8.00
5.00
2.00
7.00
9.00
4.00
3.00
Cis303a_chapt03-2a.ppt
10.00
Linked Lists
(Page 96)
• Insert a new element
6.00
1.00
8.00
5.00
2.00
7.00
4.50
4.00
3.00
Cis303a_chapt03-2a.ppt
9.00
10.00
Doubly Linked Lists
(Page 97)
• Each element points to the next element as
well as the preceding element
6.00
1.00
8.00
5.00
2.00
7.00
9.00
4.00
3.00
Cis303a_chapt03-2a.ppt
10.00
Files
(Page 98)
• Groups of related records
• Are accessed via a driver for the specific
hardware device
• Are varied in type: sequential, random,
indexed
Records
• One element in a file that contains the
required information
• All data is contained in fields (unique
positions) pertinent to the data type and
information
Database
• ‘Records’ are called Tables
• Not directly accessible via programming
• Accesses data through the database engine
Cis303a_chapt03-2a.ppt
Object Oriented Programming
• Is a programming methodology not a
language
(Page 99)
•CLASS: data structure that contains both
the data and the programming code to
manipulate the data
• METHOD: the programming code to
manipulate the data
• OBJECT: an instance of the CLASS
CLASS: Customer
OBJECT
Instance
OBJECT
Instance
OBJECT
Instance
Customer 1
Customer 2
Customer 3
Methods
Methods
Methods
Cis303a_chapt03-2a.ppt
Download