boolean operations

18
Boolean Operations 1 and 1 = 1

Upload: heather-sweet

Post on 30-Dec-2015

41 views

Category:

Documents


0 download

DESCRIPTION

Boolean Operations. 1 and 1 = 1. Boolean Algebra. Boolean Logic Logical rules for dealing with true/false values Examples: You get an F if you skip the test OR if you get below 60 You can register for CS161 if you have taken CS160 AND you have taken MTH111. Boolean Operators. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Boolean Operations

Boolean Operations1 and 1 = 1

Page 2: Boolean Operations

Boolean Algebra

• Boolean Logic– Logical rules for dealing with

true/false values

• Examples:– You get an F if you skip the test OR if you get below 60– You can register for CS161 if you have taken

CS160 AND you have taken MTH111

Page 3: Boolean Operations

Boolean Operators

• Boolean Operations– Combine/modify boolean values– Computers implements as logic gate circuits

Page 4: Boolean Operations

Or Rule

• OR rule– 1 if either input is 1– 0 if they both are 0

Page 5: Boolean Operations

Or Rule

• Logic rules implemented as circuits• Can represent anything with true/false values

You get an F if you skip the test OR if you get below 60

Page 6: Boolean Operations

And Rule

• AND produces – 1 if both inputs are 1– 0 if either is 0

Page 7: Boolean Operations

And Rule

• On/Off can stand for any true/false idea– You can register for CS161 if you have taken

CS160 AND you have taken MTH111

Page 8: Boolean Operations

Boolean Operators

• Truth Table :– Shows every combination of inputs and their

output

Input1 Input2 Out

0 0 0

0 1 1

1 0 1

1 1 1

Page 9: Boolean Operations

Basic Rules – 1 input

• NOT– Output is 1 if input is 0– Output is 0 if input is 1

If it is not raining my drive is easier

In Out

0 1

1 0

Page 10: Boolean Operations

Basic Rules – 2 inputs

• AND– 1 if both inputs 1– 0 otherwise

• OR– 1 if either input is 1 – 0 if both are 0

• XOR (exclusive OR)– 1 if only one input is 1– 0 if both inputs are 0 or 1

In1 In2 Out

0 0 0

0 1 0

1 0 0

1 1 1In1 In2 Out

0 0 0

0 1 1

1 0 1

1 1 1

In1 In2 Out

0 0 0

0 1 1

1 0 1

1 1 0

Page 11: Boolean Operations

OR vs XOR

• In English "or" used for OR and XOR

– You can either pick up your room or you can come help do the laundry

– You can have an ice cream cone or a two cookies

Page 12: Boolean Operations

Not Rules

• OR– 1 if either input is 1 – 0 if both are 0

• NOR (not OR)– 0 if either input is 1 – 1 if both are 0

In1 In2 Out

0 0 0

0 1 1

1 0 1

1 1 1

In1 In2 Out

0 0 1

0 1 0

1 0 0

1 1 0

• "Not" rules do opposite:

Page 13: Boolean Operations

Other NOT rules

• AND

• XOR

In1 In2 Out

0 0 0

0 1 0

1 0 0

1 1 1

In1 In2 Out

0 0 0

0 1 1

1 0 1

1 1 0

• NAND

• XNOR

In1 In2 Out

0 0 1

0 1 1

1 0 1

1 1 0

In1 In2 Out

0 0 1

0 1 0

1 0 0

1 1 1

Page 14: Boolean Operations

Applying rules

• Rules only work on two inputs• Bit sequences processed on bit at a time

EX: Combine with ORInput0: 0 0 1 0

Input1: 1 0 1 0

Output:

Page 15: Boolean Operations

Combining Bits

• Can apply a rule to combine two bit sequences:– Apply rule to each pair

EX: Combine with OR

Input0: 0 0 1 0

Input1: 1 0 1 0

Output: 0

Page 16: Boolean Operations

Combining Bits

• Can apply a rule to combine two bit sequences:– Apply rule to each pair

EX: Combine with OR

Input0: 0 0 1 0

Input1: 1 0 1 0

Output: 1 0

Page 17: Boolean Operations

Combining Bits

• Can apply a rule to combine two bit sequences:– Apply rule to each pair

EX: Combine with OR

Input0: 0 0 1 0

Input1: 1 0 1 0

Output: 0 1 0

Page 18: Boolean Operations

Combining Bits

• Can apply a rule to combine two bit sequences:– Apply rule to each pair

EX: Combine with OR

Input0: 0 0 1 0

Input1: 1 0 1 0

Output: 1 0 1 0