Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #91415

Re: unsigned int

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: unsigned int
Date 2016-08-01 07:33 +1200
Message-ID <e0723vFm9nU1@mid.individual.net> (permalink)
References <unsigned-20160731163521@ram.dialup.fu-berlin.de> <lnmvkx63ek.fsf@kst-u.example.com> <c6056514-d93d-4aa7-8464-74a357872a13@googlegroups.com>

Show all headers | View raw


On 08/ 1/16 07:28 AM, supercat@casperkitty.com wrote:
> On Sunday, July 31, 2016 at 1:58:20 PM UTC-5, Keith Thompson wrote:
>> In C90, an unsuffixed decimal integer constant is of type int, long
>> int, or unsigned long int, the first in which it can be represented.
>>
>> In C99, this changed to int, long int, and long long int; an
>> unsuffixed decimal integer constant is never of an unsigned type.
>> This is unchanged in C11.
>
> Over the years, I've come to see the wisdom of Java's approach of requiring
> that long constants be suffixed; if one has a piece of C code like:
>
> #define SCALE_FACTOR 2500000000
>
>      int64_t scale_value(int32_t x) { return SCALE_FACTOR*2500000000; }
>
> and the scale factor needs to be reduced by 20%, it's hardly obvious
> that changing it to 2000000000 would break the code unless a suffix is
> added.  If the original had to be written as 2500000000LL, changing the
> numeric value would not affect the type of the value.

Or better still C had proper const so all of these ghastly macro 
constants could be banished for ever...

-- 
Ian

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: unsigned int Keith Thompson <kst-u@mib.org> - 2016-07-31 11:58 -0700
  Re: unsigned int supercat@casperkitty.com - 2016-07-31 12:28 -0700
    Re: unsigned int Ian Collins <ian-news@hotmail.com> - 2016-08-01 07:33 +1200
      Re: unsigned int Les Cargill <lcargill99@comcast.com> - 2016-07-31 17:06 -0500

csiph-web