Thread: Help me with boolean algebra!!!

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    10

    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

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    The Autodidact Dante Wingates's Avatar
    Join Date
    Apr 2010
    Location
    Valhalla
    Posts
    56

    Cool

    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...

    About XOR...

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

    The result will be 0 if both are equal, 1 otherwise
    Last edited by Dante Wingates; 06-20-2010 at 10:29 AM.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    10
    Thank you guys so much!
    I understand it now alot more

  5. #5
    Registered User
    Join Date
    Jun 2010
    Posts
    10
    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)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Boolean algebra
    By akansha in forum General Discussions
    Replies: 6
    Last Post: 04-03-2010, 11:52 AM
  2. boolean algebra....urgent help needed!
    By Saimadhav in forum C++ Programming
    Replies: 1
    Last Post: 07-28-2008, 07:22 AM
  3. Looking for a Boolean Algebra site
    By Majin_Flack38 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 11-21-2002, 12:03 PM
  4. Replies: 4
    Last Post: 05-03-2002, 09:40 PM
  5. pop quiz on boolean algebra
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 09-27-2001, 07:11 AM