# Help me with boolean algebra!!!

• 06-20-2010
blakjakd
Help me with boolean algebra!!!
I have just started getting into to C++ programming and was reading the tutorial on this website.
When I got to the part about boolean algebra i got stuck
This came straight from Wikipedia.
Introduction to Boolean algebra - Wikipedia, the free encyclopedia
Will someone explain this to me?

In summary the three basic Boolean operations can be defined arithmetically as follows.
x∧y = xy
x∨y = x + y - xy
¬x = 1 - x
• 06-20-2010
Elysia
x∧y = xy -> x AND y. If both x and y is 1, then the result is one; otherwise 0. As you would get by multiplying x and y.
x∨y = x + y - xy -> x OR y. If either x or y is 1, then the result is one. If both are 0, the result is 0. Example: 1 + 1 - 1 * 1 = 1. 1 + 0 - 1 * 0 = 1.
¬x = 1 - x -> NOT x. That is, -x. If x is one, the result is 0 and vice versa. Example: 1 - 1: 0. 1 - 0: 1.
• 06-20-2010
Dante Wingates
I'll try to explain...

"*" = "AND", + = "OR", 1 = on(true), 0 = off(false). Now imagine a circuit:
Code:

`-----A-----`
if A is on, then the electrical current will go throught... In other words:

1 * 0 = 0
0 * 0 = 0
1 * 1 = 1
0 * 1 = 0

or simply A * B = AB

now imagine another kind of "circuit":
Code:

```    _A_  ---|___|----       B```
What happens if you turn on A "OR" B? electrical current will pass throught if one or both are on. So:

1 + 0 = 1
1 + 1 = 1
0 + 0 = 0
0 + 1 = 1

Or simply A + B = A + B

Then if A = 0, A * B = A(0 * ?), A + B = B(0 + ?)

NOT(~ in C++) simply inverts.. So if A = 0, ~A = 1
| in C++ = OR(+)
& in C++ = AND(*)
^ in C++ = XOR(Exclusive OR)

Now you should understand, I think...

if you forget something, remember the circuit thing...

One last example:
Code:

```        __A__   ---A--|_____|------           B```
It is the same as A * (A + B).

The result should be easy to calculate, right? A * (A + B) = A

Sorry if it is any hard to understand, but my english is not the best to explain this kind of thing... Its almost as "easy" as explain physics in another language...

1 + 1 = 0
0 + 1 = 1
1 + 0 = 1
0 + 0 = 0

The result will be 0 if both are equal, 1 otherwise
• 06-21-2010
blakjakd
Thank you guys so much!
I understand it now alot more
• 06-21-2010
blakjakd
would anyone mind giving me a couple more easy problems like these?

A. !( 1 || 0 ) ANSWER: 0
B. !( 1 || 1 && 0 ) ANSWER: 0 (AND is evaluated before OR)
C. !( ( 1 || 0 ) && 0 ) ANSWER: 1 (Parenthesis are useful)