Top Banner
Discrete Structures Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 2.5 Application: Number Systems and Circuits for Addition Counting in binary is just like counting in decimal if you are all thumbs. – Glaser and Way
16

Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

Jan 02, 2016

Download

Documents

Mercy Davidson
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: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

1

Discrete Structures

Chapter 2: The Logic of Compound Statements

2.5 Application: Number Systems and Circuits for Addition

Counting in binary is just like counting in decimal if you are all thumbs.

– Glaser and Way

Page 2: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

2

Decimal Notation

• Decimal notation (base 10) expresses a number as a string of digits in which each digit’s position indicates the power of 10 by which it is multiplied.

• For example:

3 2 1 0

5280 5 1000 2 100 8 10 0 1

5 10 2 10 8 10 0 10

Page 3: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

3

Decimal Notation

• Decimal notation is based on the fact that any positive integer can be written uniquely as a sum of products of the form

where n is a nonnegative integer and each d is one of the decimal digits 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9.

10nd

Page 4: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

4

Binary Notation

• In computer science, base 2 notation, or binary notation, is of special importance because the signals used in modern electronics are always in one of only two states.

• Any integer can be represented uniquely as a sum of products of the form

where each n is an integer and each d is one of the binary digits 0 or 1.

2nd

Page 5: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

5

Example – pg. 94 # 2 & 3

• Represent the decimal integers in binary notation.

2. 55

3. 287

Page 6: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

6

Converting Binary to Decimal

• Represent the integers in decimal notation.

211001

Page 7: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

7

Adding in Binary Notation

• Addition in binary notation is similar to addition in decimal notation, except that only 0's and 1's can be used, instead of the whole spectrum of 0-9. This actually makes binary addition much simpler than decimal addition, as we only need to remember the following:

0 + 0 = 00 + 1 = 11 + 0 = 11 + 1 = 10

Page 8: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

8

Binary Addition Example

1012

+1012

Page 9: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

9

Binary Subtraction

• Binary subtraction is simplified as well, as long as we remember how subtraction and the base 2 number system. Let's look at two examples.  

1112 10102

  - 102 - 1102  

Page 10: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

10

Compliments

• Given a positive integer a, the two’s compliment of a relative to a fixed bit length n is the n-bit binary representation of

2n a

Page 11: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

11

Finding a Two’s Complement

• To find the 8-bit two’s complement of a positive integer a that is at most 255:–Write the 8-bit binary representation for a.– Flip the bits (switch all the 1’s to 0’s and 0’s to

1’s).– Add 1 in binary notation.

Page 12: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

12

Example – pg. 94 # 24

• Find the 8-bit two’s compliment for the integer below.

67

Page 13: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

13

Hexadecimal Notation

• Base 16 notation, or hexadecimal notation can be represented uniquely as a sum of products of the form

where each n is an integer and each d is one of the integers 0 to 15. 10 through 15 are represented by A, B, C, D, E and F.

16nd

Page 14: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

14

Example – pg. 95 #39

• Convert the integer from hexadecimal to decimal notation.

E0D16

Page 15: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

15

Example – pg. 95 #42

• Convert the integer from hexadecimal to binary notation.

B53DF816

Page 16: Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.

2.5 Application: Number Systems and Circuits for Addition

16

Example – pg. 95 #42

• Convert the integer from binary to hexadecimal notation.

001011102