Velocity Reviews > Annoying compiler warning

Annoying compiler warning

Richard Heathfield
Guest
Posts: n/a

 12-20-2007
James Kuyper said:

> Walter Roberson wrote:
>>
>> Theoretically, UINT_MAX could be even,

>
> the number of value bits in an unsigned type, the corresponding maximum
> is 2^N-1, which is inherently never a negative number.

ITYM "never an even number".

But of course, it is easy to show that this is wrong. If N is, say,
15.000044+ (i.e. if there are 15.000044+ value bits in the unsigned type),
then the maximum is 32768, which is an even number.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999

James Kuyper
Guest
Posts: n/a

 12-20-2007
Richard Heathfield wrote:
> James Kuyper said:
>
>> Walter Roberson wrote:
>>> Theoretically, UINT_MAX could be even,

>> the number of value bits in an unsigned type, the corresponding maximum
>> is 2^N-1, which is inherently never a negative number.

>
> ITYM "never an even number".
>
> But of course, it is easy to show that this is wrong. If N is, say,
> 15.000044+ (i.e. if there are 15.000044+ value bits in the unsigned type),
> then the maximum is 32768, which is an even number.

I suppose you're correct; the standard never specifically requires that
there be an integer number of value bits.

Eric Sosman
Guest
Posts: n/a

 12-20-2007
Richard Heathfield wrote:
> James Kuyper said:
>
>> Walter Roberson wrote:
>>> Theoretically, UINT_MAX could be even,

>> the number of value bits in an unsigned type, the corresponding maximum
>> is 2^N-1, which is inherently never a negative number.

>
> ITYM "never an even number".
>
> But of course, it is easy to show that this is wrong. If N is, say,
> 15.000044+ (i.e. if there are 15.000044+ value bits in the unsigned type),
> then the maximum is 32768, which is an even number.

The Standard requires a "pure binary representation," but
the representation you suggest can only be called "impure."

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid

santosh
Guest
Posts: n/a

 12-20-2007
James Kuyper wrote:

> Richard Heathfield wrote:
>> James Kuyper said:
>>
>>> Walter Roberson wrote:
>>>> Theoretically, UINT_MAX could be even,
>>> N is the number of value bits in an unsigned type, the corresponding
>>> maximum is 2^N-1, which is inherently never a negative number.

>>
>> ITYM "never an even number".
>>
>> But of course, it is easy to show that this is wrong. If N is, say,
>> 15.000044+ (i.e. if there are 15.000044+ value bits in the unsigned
>> type), then the maximum is 32768, which is an even number.

>
> I suppose you're correct; the standard never specifically requires
> that there be an integer number of value bits.

The standard never specifically requires C to be restricted to computer
programming alone.

Chris Dollin
Guest
Posts: n/a

 12-20-2007
Eric Sosman wrote:

> Richard Heathfield wrote:

>> But of course, it is easy to show that this is wrong. If N is, say,
>> 15.000044+ (i.e. if there are 15.000044+ value bits in the unsigned
>> type), then the maximum is 32768, which is an even number.

>
> The Standard requires a "pure binary representation," but
> the representation you suggest can only be called "impure."

Rubbish. "Bloody stupid" would be a reasonable alternative.

--
NonJohnson Hedgehog
"Our future looks secure, but it's all out of our hands"
- Magenta, /Man and Machine/

CBFalconer
Guest
Posts: n/a

 12-20-2007
Eric Sosman wrote:
>

.... snip ...
>
> The Standard requires a "pure binary representation," but
> the representation you suggest can only be called "impure."

Ahh, now we are getting to something of general interest.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Walter Roberson
Guest
Posts: n/a

 12-20-2007
In article <(E-Mail Removed)>,
Eric Sosman <(E-Mail Removed)> wrote:

> The Standard requires a "pure binary representation," but
>the representation you suggest can only be called "impure."

Is that the C99 Standard? Is there a corresponding C89 clause?

I've been reviewing C89 but I have not yet found in there any
requirement of binary representation, beyond that implied by the definition
of "bit" and "byte". I also have not found any requirement in C89
that the complete possible span of binary be usable as values.

If there is anything in C89 that would prevent UINT_MAX from being
2^N-2 with 2^N-1 reserved as a trap value, could someone point me
to the relevant C89 clauses?
--
"All is vanity." -- Ecclesiastes

Ben Pfaff
Guest
Posts: n/a

 12-20-2007
http://www.velocityreviews.com/forums/(E-Mail Removed)-cnrc.gc.ca (Walter Roberson) writes:

> In article <(E-Mail Removed)>,
> Eric Sosman <(E-Mail Removed)> wrote:
>
>> The Standard requires a "pure binary representation," but
>>the representation you suggest can only be called "impure."

>
> Is that the C99 Standard? Is there a corresponding C89 clause?

From C89 6.1.2.5 "Types": "The representations of integral types
shall defines values by use of a pure binary numeration system."
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa6 7f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1utchar(a[i&15]);break;}}}

Walter Roberson
Guest
Posts: n/a

 12-20-2007
In article <(E-Mail Removed)>,
Ben Pfaff <(E-Mail Removed)> wrote:
>(E-Mail Removed)-cnrc.gc.ca (Walter Roberson) writes:

>> In article <(E-Mail Removed)>,
>> Eric Sosman <(E-Mail Removed)> wrote:

>>> The Standard requires a "pure binary representation," but
>>>the representation you suggest can only be called "impure."

>> Is that the C99 Standard? Is there a corresponding C89 clause?

>From C89 6.1.2.5 "Types": "The representations of integral types
>shall defines values by use of a pure binary numeration system."

Thanks. It appears the C89 clause is 3.1.2.5; "6.1.2.5" must be the C90
numbering.

I do see the quoted sentance in C89 now, but even with all of the
discussions there about subranges and representations, it is not
yet clear to me that in C89, UINT_MAX could not be 2^N-2 with 2^N-1
reserved. (It would require more than 16 bits for int, but that's not
difficult at all these days.)
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec

jameskuyper@verizon.net
Guest
Posts: n/a

 12-20-2007
Walter Roberson wrote:
....
> If there is anything in C89 that would prevent UINT_MAX from being
> 2^N-2 with 2^N-1 reserved as a trap value, could someone point me
> to the relevant C89 clauses?

Well, the fact that the standard didn't officially acknowledge the
possibility of trap values until C99 would be a bit of a barrier to
that possibility.