Top Banner
Positional Number Systems M260 1.5
29

Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Jan 02, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Positional Number Systems

M260 1.5

Page 2: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Decimal Review

• 5049 = 5(1000) + 0(100) + 4(10) + 9(1)• 5049 = 5·103 + 0·102 + 4·101 + 9·100

place 103 102 101 100

digit 5 0 4 9

Page 3: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Representation

• 27 = 16 + 8 + 2 + 1• 27 = 1·24 + 1·23 + 0·22 + 1·21 + 1·20

• 27 = 110112

place 24 23 22 21 20

digit 1 1 0 1 1

Page 4: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Some Binary Representations010 ?2

110 ?2

210 ?2

310 ?2

410 ?2

510 ?2

610 ?2

710 ?2

810 ?2

910 ?2

Page 5: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Some Binary Representations010 02

110 12

210 102

310 112

410 1002

510 1012

610 1102

710 1112

810 10002

910 10012

Page 6: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Powers of Two

210 29 28 27 26 25 24 23 22 21 20

1024 512 256 128 64 32 16 8 4 2 1

Page 7: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Binary to Decimal

210 29 28 27 26 25 24 23 22 21 20

1024 512 256 128 64 32 16 8 4 2 1

1 1 0 1 0 12

Page 8: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Binary to Decimal

210 29 28 27 26 25 24 23 22 21 20

1024 512 256 128 64 32 16 8 4 2 1

0 0 0 0 0 1 1 0 1 0 1

1 1 0 1 0 12

32 + 16 + 4 + 1 = 53

Page 9: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Decimal to Binary

• 20910 = 128 + smaller number

• = 1(128) + 81

• = 1(128) + 64 + smaller number

• = 1(128) + 1(64) + 17

• = 1(128) + 1(64) + 0(32) + 1(16) + 11(128)+1(64)+0(32)+1(16)+0(8)+0(4)+0(2)+1(1)

= 1 1 0 1 0 0 0 12

Page 10: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Addition

• • 1 1 0 1

+ 1 1 1

12

+ 12

1 02

12

12

+ 12

1 12

Page 11: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Addition

• 1 carry• 1 1 0 1

+ 1 1 1 0

12

+ 12

1 02

12

12

+ 12

1 12

Page 12: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Addition

• 1 1 carry• 1 1 0 1

+ 1 1 1 0 0

12

+ 12

1 02

12

12

+ 12

1 12

Page 13: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Addition

• 1 1 1 carry• 1 1 0 1

+ 1 1 1 1 0 0

12

+ 12

1 02

12

12

+ 12

1 12

Page 14: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Binary Addition

• 1 1 1 carry• 1 1 0 1

+ 1 1 11 0 1 0 0

12

+ 12

1 02

12

12

+ 12

1 12

Page 15: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Decimal System

•1 0 0 010

- 5 810

Page 16: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Decimal System

• 9 9 10 borrowing1 0 0 010

- 5 810

Page 17: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Decimal System

• 9 9 10 borrowing1 0 0 010

- 5 810

9 4 2

Page 18: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Binary System

•1 1 0 0 0 - 1 0 1 1

Page 19: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Binary System

• 0 1 1 10 borrowing1 1 0 0 0 - 1 0 1 1

Page 20: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Subtraction in Binary System

• 0 1 1 10 borrowing1 1 0 0 0 - 1 0 1 1 1 1 0 1

Page 21: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Two’s Complement Arithmetic

• Computers often use 2’s complement arithmetic for working with signed numbers

• 2’s complement of a in n-bit arithmetic is the binary representation of 2n – a

Page 22: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Two’s Complement Example

• The 8 bit representation of -27 is

• ( 28 – 27)10 = 22910

= 1 1 1 0 0 1 0 12

• Or flip the bits and add one

• -27 = -000110112

• = 11100100 + 1

• = 11100101

Page 23: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Two’s Complement Arithmetic

• To subtract, take the two’s complement and then add.

• Otherwise just add the binary numbers and throw away any positions greater than 2n-1.

• If -2n-1 result < 2n-1 then everything is fine.

• Otherwise you have an overflow.

Page 24: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Hexadecimal RepresentationsDecimal Hexadecimal Binary

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Page 25: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Hexadecimal RepresentationsDecimal Hexadecimal Binary

0 0

1 1

2 2

3 3

4 4

5 5

6 6

7 7

8 8

9 9

10 A

11 B

12 C

13 D

14 E

15 F

Page 26: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Hexadecimal RepresentationsDecimal Hexadecimal Binary

0 0 0000

1 1 0001

2 2 0010

3 3 0011

4 4 0100

5 5 0101

6 6 0110

7 7 0111

8 8 1000

9 9 1001

10 A 1010

11 B 1011

12 C 1100

13 D 1101

14 E 1110

15 F 1111

Page 27: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Hexadecimal to Decimal

• 3CF16

• = 3(162) + 12(161) + 15(160)

• = 97510

Page 28: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Hexadecimal to Binary

• C50A16

• C 5 0 A

• 1100 0101 0000 1010

Page 29: Positional Number Systems M260 1.5. Decimal Review 5049 = 5(1000) + 0(100) + 4(10) + 9(1) 5049 = 5·10 3 + 0·10 2 + 4·10 1 + 9·10 0 place10 3 10 2 10 1.

Convert Binary to Hexadecimal

• 0100 1101 1010 1001

• 4 D A 9