logical not !7 logical whaaaa?

This is a discussion on logical not !7 logical whaaaa? within the C Programming forums, part of the General Programming Boards category; My question is, what does the logical not do when next a a variable, IE x=7; printf("%d",!x); gives me zero, ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    5

    logical not !7 logical whaaaa?

    My question is, what does the logical not do when next a a variable, IE

    x=7;

    printf("%d",!x);

    gives me zero, though I don't understand what is being negated, what does NOT 7 mean? I under stand not 0 being one and not 1 being 0, and

    if variable != blah blah blah then...

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It is a boolean operator. Anything non-zero is considered true, and anything else (zero) is considered false. Thus, !7 is the same as !1.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    5
    Dude, you are the man (or woman) of your time and place, that's what I thought, but didn't want to make assumptions. Thanks so much!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Physical and Logical Memory.
    By TheUmer in forum General Discussions
    Replies: 3
    Last Post: 11-04-2010, 05:28 AM
  2. Logical! Logical! Why do you have to be so Logical?
    By g8ortech14 in forum C Programming
    Replies: 24
    Last Post: 09-20-2010, 03:40 PM
  3. Codeblocks and logical operators
    By fhbwghads in forum C++ Programming
    Replies: 2
    Last Post: 12-07-2008, 05:22 AM
  4. Logical Error
    By gardenair in forum C Programming
    Replies: 2
    Last Post: 04-06-2003, 05:18 PM
  5. Size of 1 pixel
    By ooosawaddee3 in forum C++ Programming
    Replies: 4
    Last Post: 07-26-2002, 09:06 PM

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