That probably has to with the fact that you're using an int. An int is usually 4 bytes, so the values it can take ranges from 0-2^31 |
I know it is. Note that the code says
if (input > 2000000000 && input < -2000000000)
, which is actually smaller than the maximum you can store as an
int
. However, when you enter anything over 2.2bil,
int input
stores 2147483648 (which is greater than the the limit defined by the above condition) and proceeds with the program ignoring the
input
limits in the
if
statement. Can't figure out why it does so.
you can find the maximum with <limits> |
I know what
int
limit is, that's why I hardcoded the limits to +-2bil.
Really? The whole point of the exercise is to write that program using what you've learned so far ('switch' isn't on that list yet). I know I can shorten the code significantly by using 'switch' & arrays, but, again, that's not the point of the exercise.