Thread: Boolean Values

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    4

    Boolean Values

    Assume Boolean values have been assigned to A, B, and C as
    A= true; B= false; C= True

    Indicate wether it is true or false.

    (A && B) || (A && C)

    How would I go about doing this?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    Evaluate the (A && B) part
    Evaluate the (A && C) part
    Evaluate those two results above combined with ||.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    haha, can't you copy your homework off of some dorky kid near you? is that even computer science homework?
    either way, i'll explain it.

    the equation in question is as follows, assuming A and C are true, and B is not.

    Code:
    (A && B) || (A && C)
    here are some rules about dealing with boolean:

    in an "and" statement (&&), if any of the values at all are false, the
    whole thing is false.

    in an "or" statement (||), it checks the value of the first piece of code, and if it is true, it will not read the second piece of code; it will simply mark itself "true." however, if the first segment of code is false, then it will check the second segment. if either of these segments are true, the entire statement is true.

    so, in this case, because the whole line of code exists within an "or" statement, we look at the first one first, then if it's false, we look at the second one, and if either of them were true, it's true.

    so, the first one, a && b = true && false. one of them is false, so the first segment is false. let's look at the second one.

    A && C = true and true, that means this section is true, because none of the values are false.

    so, we've got that the first value is false, and the second is true.

    the or statement is true if any of the results are true, and one of them is, therefore the entire statement is true.

    -n3v
    Last edited by n3v; 04-06-2006 at 07:23 AM.

  4. #4
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    It sounds like Electronics homework to me.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    How to write Boolean expressions in the real world:

    Z (output) = A.B+A.C

    + = or
    . = and

  6. #6
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    real world? i assume that's electronics lingo. i've never seen boolean expressions written like that. i thought they were represented with weird little symbols when you deal with them in math.

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    4
    Hahah thanks guys. Makes more sence now.

  8. #8
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    yep it was electronic lingo

  9. #9
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    How do you represent NOT in ASCII - afaik there's no bar.

    I guess you could do

    _
    B.(A+C)

    But that's wasting a line.
    Meh.

    EDIT: wtf I put that underscore over the C, over the goddam C!
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  10. #10
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    I don't think computers were designed to make boolean expressions.

  11. #11
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    Quote Originally Posted by bumfluff
    I don't think computers were designed to make boolean expressions.
    haha. instant classic.

    hey, wait, i know what you mean:

    0 0
    1
    0001

    nope, expressions don't work very well in boolean.
    Last edited by n3v; 04-06-2006 at 09:51 AM.

  12. #12
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    IS that not binary that your are trying to write there?

  13. #13
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    ¬ is the not symbol. It's not part of tha ASCII character set, but it might be part of some 8-bit Windows character set. ~ is sometimes used as a not symbol, too (and I'm not talking about C; I'm talking about in a math class on a chalkboard), so I recommend using that for logic. For and and or, you could use /\ and \/, but base-2 modular arithmetic + and * are equivalent. (And what's with using a period for multiplication?)
    There are 10 types of people in this world, those who cringed when reading the beginning of this sentence and those who salivated to how superior they are for understanding something as simple as binary.

  14. #14
    Registered User
    Join Date
    Nov 2005
    Posts
    545
    Well in the electronic terms that me and ahluka were talking about not is a score over the letter.

  15. #15
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    regardless, it doesn't really matter, because we're just using it in c++, where thankfully it's a lot simpler. sort of.

    and yeah, that was binary. binary was kind of a representation of boolean values there though. or something.

    the thing is though, the only thing computers can really do is make boolean expressions. in binary.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Novice needs help
    By ghaasemi in forum C++ Programming
    Replies: 9
    Last Post: 05-30-2009, 08:20 AM
  2. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  3. Need help with project
    By chrisa777 in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2006, 05:01 PM
  4. Replies: 1
    Last Post: 02-03-2005, 03:33 AM
  5. adding ASCII values
    By watshamacalit in forum C Programming
    Replies: 1
    Last Post: 12-26-2002, 07:16 PM