Boolean Algebra

I was reading about boolean algebra because I am interested in different ways of comparing values.

http://en.wikipedia.org/wiki/Two-element_Boolean_algebra

I'm a little confused by what the difference between a sum and a product is though.

I can understand sum. This makes sense to me.

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


Product I'm not entirely sure how it works. I tried googling a bit but everything I've found seems to get into more advanced uses of product.

This does not make sense to me.
0.0 = 0.1 = 1.0 = 0


hmm.. is the '.' just another representation of && ?


I'm interested in learning about this because I want to figure out better ways to do comparisons. Like these are the only two ways I can think of to check if a character was not equal to 'a' or 'b'.

I'm trying to figure out if there is a way to do one check of the character X against both 'a' and 'b' at the same time so I don't have to use && or ||

If i can figure that out I might not have to make a huge list of && or || if i want to do lots of comparisons.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

int main() {

    char X;

do{
    std::cout << "Please type a character. Enter \'x\' to end program: ";
    std::cin >> X;

    if (!((X == 'a') || (X == 'b'))){
        std::cout << "Condition Check 1\n";
        std::cout << "X is not equal to \"a\" or \"b\"\n\n";
    }

    if (X != 'a' && X != 'b'){
        std::cout << "condition Check 2\n";
        std::cout << "X is not equal to \"a\" or \"b\"\n\n";
    }

}while(X != 'x');

return 0;


}
Last edited on
hmm.. is the '.' just another representation of && ?

Yep. From the wiki page that you linked:
If 1 is read as True, '+' is read as OR, and '.' as AND, and vice versa if 1 is read as False.
I see it makes sense to me if i ignore that last part
if 1 is read as False.


They tossed so many words and concepts into that definition paragraph it was information overload for me. Would have been nice if they put that sentence at the beginning instead of the end.

Thanks for clarifying for me.
You're welcome.

That part is confusing to me also. I've not heard of considering 1 as false. Danged mathematicians.

edit: typo
Last edited on
Topic archived. No new replies allowed.