Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Minimizing (Reducing) Your Boolean Logic
|
129
Solution
To fix this situation, try applying the theorems shown in Table 3-1 to minimize these
types of equations.
In Table 3-1, assume that
w, x, y, and z are all variables of type bool. The theorem IDs
allow easy identification of which theorems are being used in the Boolean equations
that are being minimized in the Discussion section.
Discussion
Simplifying your Boolean logic will benefit your code by making it less cluttered and
making its logic clearer and more readily understood. This simplification will lessen
Table 3-1. Boolean theorems
Theorem ID Theorem definition
T0
!(!x) == x
T1 x | x == x
T2 x | !x == true
T3 (DeMorgans Theorem) !x | !y == !(x & y)
T4 x & x == x
T5 x & !x == false
T6 (DeMorgans Theorem) !x & !y == !(x | y)
T7 (Commutative Law) x | y == y | x
T8 (Associative Law) (x | y) | z == x | (y | z)
T9 (Distributive Law) x & y | x & z == x & (y | z)
T10 x | x & y = x
T11 x & y | x & !y = x
T12 (x & y) | (!x & z) | (y & z) == (x & y) | (!x & z)
T13 (Commutative Law) x & y == y & x
T14 (Associative Law) (x & y) & z == x & (y & z)
T15 (Distributive Law) (x | y) & (x | z) == x | (y & z)
T16 x & (x | y) = x
T17 (x | y) & (x | !y) = x
T18 (x | y) & (!x | z) & (y | z) == (x | y) & (!x | z)
T19 x | x | x | ... | x == x
T20 !(x | x | x | ... | x) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata