Re: !!, what is it?
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 11 Sep 2005 19:15:46 +0100
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. .
- Follow-Ups:
- Re: !!, what is it?
- From: Kenneth Brody
- Re: !!, what is it?
- References:
- !!, what is it?
- From: bjk of course
- Re: !!, what is it?
- From: Mike Wahler
- Re: !!, what is it?
- From: Cafer Şimşek
- !!, what is it?
- Prev by Date: Re: Problems about conditional compilation
- Next by Date: [ANN] SMC - State Machine Compiler v. 4.2.0 for C
- Previous by thread: Re: !!, what is it?
- Next by thread: Re: !!, what is it?
- Index(es):
Relevant Pages
|