, , ++, C.
const int MAXINT =(int)(((unsigned int)-1) >> 1), MININT = -MAXINT -1;
2, , -, MAXINT.
MAXINT , ,
#include <limits>
const int OFFICIALMAXINT = numeric_limits<int>::max();
MININT gives the same thing as you, using
#include <limits>
const int OFFICIALMININT = numeric_limits<int>::min();
Hard coding of these values, as mentioned above, is the idea of Baaad.
I prefer to beat, because I know that he is always right, and I do not need to rely on remembering the library and the syntax of the call, but it depends on the preference.
source
share