I’m working on a program where I need to know the exact boundaries on signed integers in C. My question is, if you compile a program that depends on this boundary, do you have to check the local environment to see how many bits are used to hold the value?
I’ll try to explain this better. Whenever I write a C program that works with signed integers, and part of that program depends on large numbers, I worry about a simple calculation overflowing: say 4,294,967,296 + 1. What will happen? Will this number roll over to a negative number?
Does it depend on how I compile the program (in other words, the compiler I use to compile the program) or does it depend on the environment that my .exe is run on?
Thanks for your help!
((sizeof(n) + sizeof(int) – 1) & ~(sizeof(int) – 1))
This should give you the limit