Re: !!, what is it?
- From: Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx>
- Date: Mon, 12 Sep 2005 09:36:01 +0200
Charlie Gordon wrote:
"Kenneth Brody" <kenbrody@xxxxxxxxxxx> wrote in message news:4324D57D.44516C35@xxxxxxxxxxxxxx
Flash Gordon wrote:
Cafer ÅzimÅYek wrote:
[...]
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.
[...]
Well, any C89 or later, I assume. I've worked on platforms (prior to 1989) where boolean expressions were 0 or -1.
You must have been programming in Basic!
No C implementation ever used -1 as the value of 0==0
As an aside: I recall seeing some platform specific headers which went for the all-bits-one representation of "true" -- but the C implementations gave 1 for !!TRUE as well...
One other explanation for this misunderstanding is that you may have been using 1 bit bitfields: it is implementation defined whether these have values 0 and 1 or 0 and -1. As far as I recall, C99 did not change that.
Naive question after having a look at C99, 6.7.2.1: Does this ambiguity only hold for "int" bitfields or also for "signed int" bitfields?
Cheers Michael -- E-Mail: Mine is an /at/ gmx /dot/ de address. .
- Follow-Ups:
- Re: !!, what is it?
- From: Tim Woodall
- 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
- Re: !!, what is it?
- From: Flash Gordon
- Re: !!, what is it?
- From: Kenneth Brody
- Re: !!, what is it?
- From: Charlie Gordon
- !!, what is it?
- Prev by Date: Re: pointer to void property
- Next by Date: floating format not linked
- Previous by thread: Re: !!, what is it?
- Next by thread: Re: !!, what is it?
- Index(es):