Someone explain it please

This is a discussion on Someone explain it please within the C++ Programming forums, part of the General Programming Boards category; !(1 && !(0 || 1)) can u tell me what each part does and what it is? try make it ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    25

    Someone explain it please

    !(1 && !(0 || 1))


    can u tell me what each part does and what it is?

    try make it clear and simple for me please

    and wondering on how to evaluate that

  2. #2
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903

    Re: Someone explain it please

    !(1 && !(0 || 1))
    we'll start from the inside: (0 || 1)
    0 || 1 == 1 because it's testing if either 0 OR 1 are true, and one of them IS
    then, we have the ! right before that, so that inverts the current value, so that now we have 0

    then it tests (1 && 0) and since not BOTH of them aren't 1, then it equals a 0, making it !(0)

    so, the end result is 1/true

    -edit-
    typo.....
    Last edited by jverkoey; 08-13-2003 at 06:07 PM.

  3. #3
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138

    Re: Someone explain it please

    Originally posted by yakabod
    !(1 && !(0 || 1))


    can u tell me what each part does and what it is?

    try make it clear and simple for me please

    and wondering on how to evaluate that
    To start, 0 is FALSE. And Anything other than 0 (in most cases 1) is TRUE. I assume the question is whether that statement evaluates to TRUE or FALSE. If you didnt know, ! means NOT. So if the statement is currently true, the ! changes it to false (as in NOT TRUE). && Means AND. A statement using && returns TRUE only if both are TRUE. || is OR. This returns TRUE if one of them are TRUE. And remember, you work your way out of the parantaces (Like Order of Operations in math class). So, the first thing you would evaluate is (0 || 1). This evaluates to 1 (TRUE) because like stated above, only one of the numbers needs to be TRUE for this to equal TRUE. So now, our statement looks like this:
    !(1 && !(1))
    The next step is the !(1). This obviously returns 0 (or FALSE). So now we have:
    !(1 && 0)
    Now, since we know that both have to be TRUE for the && statement to be TRUE, we get this:
    !(0)
    !0 must be a value other than 0, which means your statement == TRUE

    I hope I explained it clearly enough and didn't ramble too much .

    EDIT: Looks like jverkoey beat me to it
    Last edited by o0obruceleeo0o; 08-13-2003 at 06:05 PM.

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    The next step is the !(1). This obviously returns 0 (or FALSE). So now we have:

    So how does this become false? because ! means NOT right? so making...


    !(1) //Not 1 But 0

    will that be right?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you explain these bitwise operations?
    By 6tr6tr in forum C++ Programming
    Replies: 6
    Last Post: 10-29-2008, 02:19 PM
  2. Please explain?
    By neo_phyte in forum C Programming
    Replies: 3
    Last Post: 08-25-2006, 06:23 AM
  3. Can someone explain to me what this code means
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 12-22-2002, 12:36 PM
  4. Replies: 4
    Last Post: 11-19-2002, 09:18 PM
  5. Can someone explain "extern" to me?
    By valar_king in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2001, 01:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21