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

This is a discussion on !(1 && !(0 || 1)) Help within the C++ Programming forums, part of the General Programming Boards category; If this is true, !(1 && !(0 || 1)) why exactly? Can anyone explain how this is to be read?...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    3

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

    If this is true, !(1 && !(0 || 1)) why exactly?
    Can anyone explain how this is to be read?

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,535
    0 || 1
    !(0 || 1)
    1 && !(0 || 1)
    !(1 && !(0 || 1))
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,752
    actually, go from left to right. parentheses do not change the direction AND operates in, but parentheses can still effect evaluation of either side:
    Code:
    int * p = 0;
    if ( !( p && !( *p || 0 ) ) )
       printf ( "citizen is right: p == %p\n", ( void * )p );

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    2,053
    Quote Originally Posted by scope View Post
    If this is true, !(1 && !(0 || 1)) why exactly?
    Can anyone explain how this is to be read?
    !(1 && !(0 || 1))
    = !(1 && !(1))
    = !(1 && 0)
    = !(0)
    = 1

    But note that, the individual terms are evaluated from left to right.
    Last edited by King Mir; 02-20-2008 at 11:25 PM. Reason: changed it to be true to order of evaluation.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 01:13 AM
  2. process killer on a loop
    By Anddos in forum Windows Programming
    Replies: 8
    Last Post: 01-11-2006, 01:50 AM
  3. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  4. Massive Function Problem
    By Marc Sharp in forum C Programming
    Replies: 10
    Last Post: 11-19-2003, 08:49 PM
  5. Tic Tac Toe Help
    By aresashura in forum C++ Programming
    Replies: 1
    Last Post: 11-21-2001, 12:52 PM

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