Top Banner
ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6 th Edition, by Roth and Kinney, and were used with permission from Cengage Learning.
42

ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Dec 22, 2015

Download

Documents

Leo Burns
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: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

ECE 301 – Digital Electronics

Number Systems and Conversion,Binary Arithmetic,

andRepresentation of Negative Numbers

(Lecture #10)

The slides included herein were taken from the materials accompanying Fundamentals of Logic Design, 6th Edition, by Roth and Kinney,

and were used with permission from Cengage Learning.

Page 2: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 2

52

What does this number represent? Consider the “context” in which it is used.

Page 3: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 3

1011001.101

What is the decimal value of this number? Consider the base (or radix) of this number.

Page 4: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 4

Number Systems

Page 5: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 5

Number Systems

R is the radix (or base) of the number system. Must be a positive number R digits in the number system: [0 .. R-1]

Important number systems for digital systems: Base 2 (binary) [0, 1] Base 8 (octal) [0 .. 7] Base 16 (hexadecimal) [0 .. 9, A .. F]

Page 6: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 6

Number Systems

Positional Notation

[a4a

3a

2a

1a

0.a

-1a

-2a

-3]

R

ai = ith position in the numberR = radix or base of the number

radix point

Page 7: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 7

Number Systems

Power Series Expansion

D = an x R4 + a

n-1 x R3 + … + a

0 x R0

+ a-1

x R-1 + a-2 x R-2 + … a

-m x R-m

D = decimal valueai = ith position in the numberR = radix or base of the number

Page 8: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 8

Number Systems: Example

Decimal

927.4510 = 9 x 102 + 2 x 101 + 7 x 100 +4 x 10-1 + 5 x 10-2

Page 9: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 9

Number Systems: Example

Binary

1101.1012 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20 +1 x 2-1 + 0 x 2-2 + 1 x 2-3

Page 10: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 10

Number Systems: Example

Octal

326.478 = 3 x 82 + 2 x 81 + 6 x 80 +4 x 8-1 + 7 x 8-2

Page 11: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 11

Number Systems: Example

Hexadecimal

E5A.2B16 = 14 x 162 + 5 x 161 + 10 x 160 +2 x 16-1 + 11 x 16-2

Page 12: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 12

Conversion between Number Systems

Page 13: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 13

Use repeated division to convert a decimal integer to any other base.

Conversion of a Decimal Integer

Page 14: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 14

Conversion of a Decimal Integer

Example:

Convert the decimal number 57 to binary and to octal:

57 / 2 = 28: rem = 1 = a0

28 / 2 = 14: rem = 0 = a1

14 / 2 = 7: rem = 0 = a2

7 / 2 = 3: rem = 1 = a3

3 / 2 = 1: rem = 1 = a4

1 / 2 = 0: rem = 1 = a5

5710

= 1110012

57 / 8 = 7: rem = 1 = a0

7 / 8 = 0: rem = 7 = a1

5710

= 718

Page 15: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 15

Use repeated multiplication to convert a decimal fraction to any other base.

Conversion of a Decimal Fraction

Page 16: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 16

Conversion of a Decimal Fraction

Example:

Convert the decimal number 0.625 to binary and to octal.

0.625 * 2 = 1.250: a-1 = 1

0.250 * 2 = 0.500: a-2 = 0

0.500 * 2 = 1.000: a-3 = 1

0.62510

= 0.1012

0.625 * 8 = 5.000: a0 = 5

0.62510

= 0.58

Page 17: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 17

Conversion of a Decimal Fraction

Example:

Convert the decimal number 0.7 to binary.

0.7 * 2 = 1.4: a-1 = 1

0.4 * 2 = 0.8: a-2 = 0

0.8 * 2 = 1.6: a-3 = 1

0.6 * 2 = 1.2: a-4 = 1

0.2 * 2 = 0.4: a-5 = 0

0.4 * 2 = 0.8: a-6 = 0

0.710

= 0.1 0110 0110 0110 ...2

process begins repeating here!

In some cases, conversion results in a repeating fraction.

Page 18: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 18

Conversion of a Mixed Decimal Number

Convert the integer part of the decimal number using repeated division.

Convert the fractional part of the decimal number using repeated multiplication.

Combine the integer and fractional parts in the new base.

Page 19: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 19

Conversion of a Mixed Decimal Number

Example:

Convert 48.562510 to binary.

Confirm the results using the Power Series Expansion.

Page 20: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 20

Conversion between Bases Conversion between any two bases can be

carried out directly using repeated division and repeated multiplication.

Base A → Base B However, it is, generally, easier to convert

Base A to its decimal equivalent and then convert the decimal value to Base B.

Base A → decimal value → Base B

Power Series Expansion Repeated Division, Repeated Multiplication

Page 21: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 21

Conversion between Bases

Conversion between binary and octal can be carried out by inspection.

Each octal digit corresponds to 3 bits 101 110 010 . 011 001

2 = 5 6 2 . 3 1

8

010 011 100 . 101 0012 = 2 3 4 . 5 1

8

7 4 5 . 3 28 = 111 100 101 . 011 010

2

3 0 6 . 0 58 = 011 000 110 . 000 101

2

Is the number 392.248 a valid octal number?

Page 22: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 22

Conversion between Bases

Conversion between binary and hexadecimal can be carried out by inspection.

Each hexadecimal digit corresponds to 4 bits 1001 1010 0110 . 1011 0101

2 = 9 A 6 . B 5

16

1100 1011 1000 . 1110 01112 = C B 8 . E 7

16

E 9 4 . D 216

= 1110 1001 0100 . 1101 00102

1 C 7 . 8 F16

= 0001 1100 0111 . 1000 11112

Note that the hexadecimal number system requires additional characters to represent its 16 values.

Page 23: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 23

Number SystemsBase: 10 2 8 16

What is the value of 12?

Page 24: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 24

Binary Arithmetic

Page 25: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 25

Binary Addition

0 0 1 1+ 0 + 1 + 0 + 1 0 1 1 10

Sum Carry Sum

Page 26: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 26

Binary Addition: Examples

01011011+ 01110010

00111100+ 10101010

10110101+ 01101100

Page 27: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 27

Binary Subtraction

0 10 1 1- 0 - 1 - 0 - 1 0 1 1 0

Difference

Borrow

Page 28: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 28

Binary Subtraction: Examples

01110101- 00110010

00111100- 10101100

10110001- 01101100

Page 29: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 29

Binary Arithmetic

Single-bit Addition Single-bit Subtraction

What logic function is this?

What logic function is this?

A B Difference

0 0 0

0 1 1

1 0 1

1 1 0

A B Carry Sum

0 0 0 0

0 1 0 1

1 0 0 1

1 1 1 0

Page 30: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 30

Binary Multiplication

0 0 1 1x 0 x 1 x 0 x 1 0 0 0 1

Product

Page 31: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 31

Binary Multiplication: Examples

0110x 1010

1011x 0110

1001x 1101

Page 32: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 32

Representation of Negative Numbers

Page 33: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 33

10011010 What is the decimal value of this number? Is it positive or negative? If negative, what representation are we using?

Page 34: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 34

bn 1– b1 b0

Magnitude

MSB Unsigned number

bn 1– b1 b0

MagnitudeSign

Signed number

bn 2–

0 denotes1 denotes

+– MSB

Unsigned and Signed Binary Numbers

Page 35: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 35

Unsigned Binary Numbers

For an n-bit unsigned binary number, all n bits are used to represent the

magnitude of the number.

** Cannot represent negative numbers.

Page 36: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 36

Unsigned Binary Numbers

For an n-bit binary number

0 <= D <= 2n – 1 where D = decimal equivalent value

For an 8-bit binary number: 0 <= D <= 28 – 1 28 = 256

For a 16-bit binary number: 0 <= D <= 216 – 1 216 = 65536

Page 37: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 37

Signed Binary Numbers

For an n-bit signed binary number, n-1 bits are used to represent the

magnitude of the number;

the leftmost bit is, generally, used to indicate the sign of the number.

0 = positive number1 = negative number

Page 38: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 38

Signed Binary Numbers

Representations for signed binary numbers:

1. Sign and Magnitude2. 1's Complement3. 2's Complement

Page 39: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 39

Sign and Magnitude

For an n-bit signed binary number, The leftmost bit is the sign bit. The remaining n-1 bits represent the

magnitude.

Includes a representation for +0 and -0

- (2n-1 – 1) <= N <= + (2n-1 – 1)

Page 40: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 40

Sign and Magnitude: Example

What is the Sign and Magnitude representation for the following decimal values, using 8 bits?

+ 97- 68- 97+ 68

Page 41: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 41

Sign and Magnitude: Example

Can the following decimal numbers be represented using 8-bit Sign and Magnitude representation?

- 212 - 127+128+255

Page 42: ECE 301 – Digital Electronics Number Systems and Conversion, Binary Arithmetic, and Representation of Negative Numbers (Lecture #10) The slides included.

Spring 2011 ECE 301 - Digital Electronics 42

Questions?