cis303a_chapt03-2a.ppt range overflow fixed length of bits to hold numeric data can hold a maximum...

21
Cis303a_chapt03- 2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) 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 --------- --- 65535 10 16 Bits Chapter 3

Upload: ralf-maxwell

Post on 12-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Range Overflow

• Fixed length of bits to hold numeric data

• Can hold a maximum positive number (unsigned)

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

3276816384

8192409620481024512256128643216

8421

------------6553510

16 Bits

Chapter 3

Page 2: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Range Overflow

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

163848192409620481024512256128643216

8421

------------+/- 3276710

• Fixed length of bits to hold numeric data

• Can hold a maximum positive and negative number (signed)

16 Bits

Sign bit – not used to hold numeric data

Page 3: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Range Overflow• Numeric range of an unsigned integer(no sign bit – all bits used for numeric data)

2n-1

n-1 = number of 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

216-1 = 215 (16 bits – 0 through 15)

215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20

3276816384

8192409620481024512256128643216

8421

------------6553510

Page 4: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Real Numbers

• Contains Whole number and fraction

• Fraction to the right of the radix point (decimal position)

100102 / 1002= 100.12

100 100100

1001

0

010

100100000

Radix(decimal point)

= 100.12

Page 5: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

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

Real Numbers

• Contains Whole number and fraction

• Fraction to the right of the radix point (decimal position)

1 0 0 . 1S X X X X X X X X X X X X X X X X . X X X X X X X X X X X X X X X

(Page 67)

2-1 = ½ = .52-2 = ¼ = .25 2-3 = 1/8 = .125 2-4 = 1/16 = .0625

4.510

Page 6: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Floating Point

• 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

(Page 77-79)

Page 7: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Character Data

• Alphabetic letters

• Numerals

• Punctuation

• Special Purpose ($,%,&,# ETC.)

String: a grouping of character data

(Page 81)

Early Computers

• Binary Coded Decimal (BCD)

• 6 bits (Octal)

• Limited character range

• Limited memory

• Slow processors

Page 8: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Character Data

Modern computers

• Extended Binary Coded Decimal Interchange Code (EBCDIC)

• 8 bits (Hexadecimal)

• Mainframes

American Standard Code for Information Interchange (ASCII)

• Data hardware communicationsPrinters, 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

(Table Page 83)

Page 9: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

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

Page 10: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

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

• 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

(Page 88)

Page 11: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

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

Page 12: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Memory Addresses

• Flat Memory Model

• Beginning byte is 0 and continues sequentially until the last byte of memory

0

1

2

3

4

5

6

7

10

11

12

13

AddressRegister

Page 13: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Memory Addresses

0

1

2

3

4

5

6

7

10

11

12

13

AddressRegister

•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

Segment

Segment

Segment

Page 14: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

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)

Page 15: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Pointers

• 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

(Page 93)

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

(Page 93)

Page 16: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

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

1.00

8.00

10.00

4.00

5.00

2.00

9.00

3.00

6.00

7.00

List(unordered)

1.00

2.00

3.00

4.00

5.00

6.00

7.00

8.00

9.00

10.00

Array(ordered)

Purchase a 5 hamburgers: got to 5th element in the array

Page 17: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Linked Lists

• A data structure that uses pointers

• Element may be scattered – do not have to be contiguous

1.00

6.00

3.00

9.00

5.00

4.00 10.00

8.00

7.002.00

(Page 95)

Page 18: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Linked Lists

• Insert a new element

1.00

6.00

3.00

9.00

5.00

4.00 10.00

8.00

7.002.00

(Page 96)

4.50

Page 19: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Doubly Linked Lists

• Each element points to the next element as well as the preceding element

1.00

6.00

3.00

9.00

5.00

4.00 10.00

8.00

7.002.00

(Page 97)

Page 20: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Files

• 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

(Page 98)

Database

• ‘Records’ are called Tables

• Not directly accessible via programming

• Accesses data through the database engine

Page 21: Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X

Cis303a_chapt03-2a.ppt

Object Oriented Programming

• Is a programming methodology not a language

•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

(Page 99)

CLASS: Customer

OBJECTInstance

Customer 1

Methods

OBJECTInstance

Customer 2

Methods

OBJECTInstance

Customer 3

Methods