Re: !!, what is it?



Cafer Şimşek wrote:
"Mike Wahler" <mkwahler@xxxxxxxxxxxx> writes:


[...]


No, ! is an operator. It's result is always either zero or one.

^^^^^^^^^^^^

I think, C standarts says something about logical operations resusts;
if the result is false, it's value is 0 (zero). if the result is true,
it's value is non-zero (like -2, -1, 2, 3, ...). So, it must NOT be
one. This difference has seen according to compiler or target
platform.

Incorrect. The result of any logical operator is *always* 0 or 1 and this is defined by the standard. What probably has you confused is that any non-zero value will act as true, so all the values you quote will act as true. However, I repeat, the boolean operators will never return any value other than 0 or 1 on *any* implementation.


For example; some compiler's headers provide TRUE and FALSE constants
like that;

#define FALSE 0
#define TRUE !FALSE

// or

#define TRUE (0==0)
#define FALSE !TRUE

In both cases you are guaranteed that TRUE == 1. -- Flash Gordon Living in interesting times. Although my email address says spam, it is real and I read it. .



Relevant Pages

  • Re: double confusion
    ... of the language doesn't act as you would like today, ... versions do act that way. ... inadequate because he could not or would not change to a new compiler. ... its abilities F77 do not provide? ...
    (comp.lang.fortran)
  • Re: [Announcement] New Project: GLADE for GNAT
    ... >> for GNAT. ... > How does this relate to the ACT GLADE releases? ... the paying customers are allways up front. ... chance in compiler options so some .o files are not generated. ...
    (comp.lang.ada)
  • Re: GNAT GPL 2005: Too clever by half?
    ... An average developer might not give it two seconds of thought and just assume that the compiler used to generate machine code from his code doesn't impose some sort of ownership rights or restrictions on his code. ... ACT can impose any restrictions they like, but I think that makes their compiler significantly less useful - and they should make it CLEAR to everyone running the compiler that by using it, they just got infected. ... Go buy a support agreement from ACT - something that is significantly ... What they need is s shrink-wrap copy of a compiler with an unrestrictive license on their end-product-code and some level of acceptable reliability and documentation. ...
    (comp.lang.ada)
  • Re: Coming home from work II
    ... Bad Ladies and bad Gentlemen hijacking the town? ... Whit a ZERO act, the Checkmate/Sting. ... My God, ...
    (rec.music.dylan)
  • Re: Extent of the "as-if" rule
    ... > It is purely pedantic because no existing compiler will remove the call ... If you are a compiler writer and you want to remove ... >> what the act of opening a file involves, ...
    (comp.lang.c)