🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3974

Re: Type of expression

#3974
From: John Winters
Date: Tue, 12 Sep 1995 15:23
34 lines
1956 bytes
In article <810609935snz@genesis.demon.co.uk>,
Lawrence Kirby  <fred@genesis.demon.co.uk> wrote:
>In article <DEHyMv.E4r@stdc.demon.co.uk>
>           clive@demon.net "Clive D.W. Feather" writes:
>
>>In article <DEG4C6.6Ao@polo.demon.co.uk>,
>>John Winters <john@polo.demon.co.uk> wrote:
>>> Surely 0x80000000L is only too big for a long int on a 32 bit machine
>>> if you intend it to be interpreted as a positive number?  It fits in a
>>> 32 bit signed int fine, and represents -2147483648.
>>
>>The C expression 0x80000000L is a way of writing the value 2147483648.
>>It is always a positive value. Since it won't fit in a 32-bin long int,
>>the language gives it the type unsigned long int.
>
>It may be worth noting that all integer constants represent positive values
>(perhaps there are theoretical circumstances where a character constant
>could end up negative). In particular something like -1 is equivalent to
>-(1) i.e. the integer constant 1 to which is applied the unary - operator.
>The result is an integral constant expression with a negative value, not an
>integer constant.
>

Could you quote a reference for this please?  (Genuine request for
enlightenment - not an attempt to dispute it.)  I've looked at the standard,
and clearly the syntax of decimal integer constants excludes the
possibility of them being negative, but I can't find anywhere where it
says that hex constants must be interpreted as positive.

TIA,
John

-- 
John Winters.  Wallingford, Oxon, England.
Technical Details
Message-ID: <DEstEs.7wJ@polo.demon.co.uk>
Path: arc1-ca.pugleaf.net!dispatch.news.demon.net!demon!polo!john
References: <42df0h$73v@elf.bsdi.com> <DEG4C6.6Ao@polo.demon.co.uk> <DEHyMv.E4r@stdc.demon.co.uk> <810609935snz@genesis.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!dispatch.news.demon.net!demon!polo!john
From: john@polo.demon.co.uk (John Winters)
Newsgroups: comp.std.c
Subject: Re: Type of expression
Date: Tue, 12 Sep 1995 15:23:15 GMT
Organization: Wallingford
Message-ID: <DEstEs.7wJ@polo.demon.co.uk>
References: <42df0h$73v@elf.bsdi.com> <DEG4C6.6Ao@polo.demon.co.uk> <DEHyMv.E4r@stdc.demon.co.uk> <810609935snz@genesis.demon.co.uk>
X-NNTP-Posting-Host: polo.demon.co.uk