Re: !!, what is it?
- From: Tim Woodall <devnull@xxxxxxxxxxxxx>
- Date: Mon, 12 Sep 2005 22:44:05 +0000 (UTC)
On Mon, 12 Sep 2005 09:36:01 +0200,
Michael Mair <Michael.Mair@xxxxxxxxxxxxxxx> wrote:
>
> 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...
>
>
int is_it_seven(int x)
{
return x==7;
}
if(is_it_seven(7) == TRUE)
printf("7 is seven\n");
else
printf("7 is not seven\n");
While I would never write the explicit test for TRUE [1], I would be
horrified at any header that defined TRUE such that this code didn't
behave as expected.
[1] Other peoples coding standards excepted.
>> 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?
>
If you are using sign-magnitude or ones complement encoding then the
possible values of a signed int bitfield will be +0 and -0 or 0 and a
trap representation.
(I hope there isn't something somewhere that says that bitfields must be
twos complement. I can't see it but I'm sure if there is someone here
will be along quickly to correct me. ;-) )
Tim.
--
God said, "div D = rho, div B = 0, curl E = - @B/@t, curl H = J + @D/@t,"
and there was light.
http://tjw.hn.org/ http://www.locofungus.btinternet.co.uk/
.
- Follow-Ups:
- Re: !!, what is it?
- From: Michael Mair
- Re: !!, what is it?
- From: Keith Thompson
- Re: !!, what is it?
- From: Gordon Burditt
- 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
- Re: !!, what is it?
- From: Michael Mair
- !!, what is it?
- Prev by Date: Re: Difference of 'also'
- Next by Date: Re: C FAQ wiki
- Previous by thread: Re: !!, what is it?
- Next by thread: Re: !!, what is it?
- Index(es):
Relevant Pages
|