[LC++]Smallest int -2147483648 or -2147483647?
Paul Gearon
gearon at ieee.org
Wed Sep 4 17:01:07 UTC 2002
On 4 Sep 2002, Dr Mark H Phillips wrote:
> int const minInt=-2147483648;
>
> I get the error:
>
> umbrella.h:43: warning: decimal integer constant is so large that it is
> unsigned
>
> Does that mean that the minimum is actually -2147483647, or does
> it mean that it is first reading (2147483648) and then applying the
> minus, thus causing a problem.
No, you were correct the first time. The minimum integer is indeed
-2147483648. If you print out minInt you'll find that it gives you the
correct value, regardless of that warning.
> If the latter, how do I form a constant containing the minimum int?
Well what you're doing works, but since I don't like warnings I'd
initialise it with:
int const minInt = 0x80000000;
This gives the same result, without the warning.
Regards,
Paul Gearon
More information about the tuxCPProgramming
mailing list