cpu data types

12
Cis303a_chapt03- 2.ppt CPU Data Types Integer Real Numbers Character Boolean Memory Address Chapter 3

Upload: april-houston

Post on 30-Dec-2015

18 views

Category:

Documents


0 download

DESCRIPTION

CPU Data Types. Chapter 3. Integer Real Numbers Character Boolean Memory Address. Integer. Integer Whole numbers No decimal places Unsigned integers Use entire by ( 8 or 6 bits) for number Lowest number is zero (0) Signed integers Use high order bit for + or – sign - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: CPU Data Types

Cis303a_chapt03-2.ppt

CPU Data Types

Integer

Real Numbers

Character

Boolean

Memory Address

Chapter 3

Page 2: CPU Data Types

Cis303a_chapt03-2.ppt

Integer

• Whole numbers

• No decimal places

• Unsigned integers

• Use entire by ( 8 or 6 bits) for number

• Lowest number is zero (0)

• Signed integers

• Use high order bit for + or – sign

• Octal machines have 5 bits for number (out of 6)Excess notation

• Hex machines have 7 bit for number (out of 8)Excess notation

Integer

Page 3: CPU Data Types

Cis303a_chapt03-2.ppt

X X X X X X

Weight value 32 16 8 4 2 1

All positions = “1” (“ON”) 1 1 1 1 1 1

3216

8421

-----63

Not counted: used for sign16

8421

-----31

Unsigned Signed

Integer

Octal6 BIT number

Page 4: CPU Data Types

Cis303a_chapt03-2.ppt

X X X X X X X X

Weight value 128 64 32 16 8 4 2 1

All positions = “1” (“ON”) 1 1 1 1 1 1 1 1

128643216

8421

-----255

Not counted: used for sign643216

8421

-----127

Unsigned Signed

Integer

Hexadecimal8 BIT number

Page 5: CPU Data Types

Cis303a_chapt03-2.ppt

Arithmetic Operations

Addition

Subtraction

Multiplication

Division

Page 6: CPU Data Types

Cis303a_chapt03-2.ppt

Addition

Add two numbers

Decimal Binary Binary bit weights

6 0110 1 + 2 + 8 = 1110 + 5 0101 ---- ------- 1110 10112

Page 7: CPU Data Types

Cis303a_chapt03-2.ppt

Subtraction

Subtract two numbers

Decimal Binary Binary bit weights

6 0110 1 + 0 + 0 + 0 = 110 - 5 - 0101 * ---- ------- 110 00002

0110-0101 -------

Borrow 1 from2s positionadd to 1s position

0101-0101 -------

Subtract 1s position

0101-0101 ------- 0

Subtract 2s position

0101-0101 ------- 00

Subtract 4s position

0101-0101 ------- 000

Subtract 8s position

0101-0101 ------- 0000

Answer is:

6- 5----- 0

1 2 3 4

5 6 7

?

Page 8: CPU Data Types

Cis303a_chapt03-2.ppt

Octal Hexadecimal

0 000 = 111 0000 = 11111 001 = 110 0001 = 1110 2 010 = 101 0010 = 11013 011 = 100 0011 = 11004 100 = 011 0100 = 10115 101 = 010 0101 = 10106 110 = 001 0110 = 10017 111 = 000 0111 = 10008 1000 = 0111 9 1001 = 0110A 1010 = 0101 B 1011 = 0100 C 1100 = 0011D 1101 = 0010E 1110 = 0001 F 1111 = 0000

Complements

• Binary numbering scheme

• Ones (1) become zero (0)

• Zeros (0) become ones (1)

Page 9: CPU Data Types

Cis303a_chapt03-2.ppt

Two’s Complement

• Binary numbering scheme

• Used to work with negative numbers

• Ones (1) become zero (0)

• Zeros (0) become ones (1)

• Data is signed if:

• Variable data type was defined as signed in the program

• The number is converted in the program

• The computer does a Subtract or Divide

• Formula for conversion

• Original binary number

• Compliment the number

• Ones to Zeros

• Zeros to Ones

• Add binary one to lowest position

• High order carry's are discarded

Computers MULTIPLY, SUBTRACT and DIVIDE by ADDITION

Page 10: CPU Data Types

Cis303a_chapt03-2.ppt

Two’s Complement

Add two numbers

Decimal Binary Binary bit weights

6 0110 1 + 2 + 8 = 1110 + 5 0101 ---- ------- 1110 10112

Page 11: CPU Data Types

Cis303a_chapt03-2.ppt

Two’s Complement

Subtract two numbers

Decimal Binary Binary bit weights

1 1

6 0110 1 + 0 + 0 + 0 = 110 - 5 +1011 * ---- ------- 110 00012

* Two’s Compliment of 5

5 = 0101 Original

Compliment 1010Add one 1

--------Two’s compliment1011

Page 12: CPU Data Types

Cis303a_chapt03-2.ppt

Computers do

SubtractionAnd

DivisionUsing

Addition and

Two’s Compliment

Summary