unsigned

Luke Powell luke@lukepowell.net
Mon Dec 4 22:17:00 GMT 2006


C tries to generate integers by default, so when you write that number,
which is larger than the signed integer boundary, it will instead
generate an unsigned integer instead and let you know about it. You
should be able to get rid of the warning by writing it as 2147483648U (U
for unsigned).

On 12/04/2006 03:48 PM, Trevis Rothwell wrote:
> Given the following program:
> 
>  int main()
>  {
>    unsigned int squiggy = 2147483648;
>  }
> 
> Compliing on GCC 3.2.3, I get the following warning:
> 
>  $ gcc foo.c
>  foo.c: In function `main':
>  foo.c:3: warning: decimal constant is so large that it is unsigned
> 
> To the best of my knowledge, 2147483648 should fit with ample room to
> spare in an unsigned (4-byte) integer.
> 
> What's going on?
> 



More information about the Gcc-help mailing list