# Trying to resyrict entry and running total to 32 bit int, but get warning

• 06-11-2011
Charbot
Trying to resyrict entry and running total to 32 bit int, but get warning
Total newbie question. I'm trying to restrict a user entry to a 32 bit integer. I keep getting the following warning and when I try to use the restriction it won't work:

[Warning] this decimal constant is unsigned only in ISO C90

This is my code:
Code:

```if(testNum == 1 && testLetter == 0) {   if(entry[0] == 45)   {                                for(i=1; i<strlen(entry); i++)       {       total = total*10+entry[i]-'0';                            }       total = total*-1;   }   else       for(i=0; i<strlen(entry); i++)       {       total = total*10+entry[i]-'0';       }  if((total > 2147483647) || (total < -2147483648) || (total+runTotal>2147483647) ||  (total+runTotal < -2147483648))  {   printf("Number out of range."); }else   runTotal += total;   total = 0;        printf("\nNumber:%d\n",runTotal);  }```
Yes I'm sure there are more efficient ways of doing this, but I'm just trying to learn C and get a feel for type sizes and how to work with them.
• 06-11-2011
brewbuck
A 32-bit signed integer can NOT hold a value larger than 2147483647. Thus, checking whether a 32-bit signed integer exceeds this value is illogical. It cannot happen. As I said in another post just a day or two ago, this is like asking, "Is this object outside the universe?" The answer is no.
• 06-11-2011
Salem
If you try to do this
Code:

```if ( a + b > INT_MAX ) {   // too late, overflow happened }```
```if ( a > INT_MAX - b ) {   // a+b would overflow, so be careful! }```