#include using namespace std; int main(void) { int32_t max = INT_MAX; int32_t max1 = INT_MAX + 1; bitset<32> bs; cout << "signed 32-bit integer range [-2^31, 2^31 - 1]\n" << endl; cout << dec << setw(25) << "INT_MAX: " << max << " " << hex << max << endl; cout << dec << setw(25) << "(1 << 31) - 1: " << ((1L << 31) - 1) << " " << hex << INT_MAX << endl; bs = INT_MAX; cout << setw(25) << "INT_MAX: " << bs << endl << endl; cout << dec << setw(25) << "INT_MIN: " << INT_MIN << " " << hex << INT_MIN << endl; cout << dec << setw(25) << "-(1 << 31): " << -(1L << 31) << " " << hex << INT_MIN << endl; cout << dec << setw(25) << "overflow: INT_MAX + 1: " << max1 << " " << hex << max1 << endl; bs = INT_MIN; cout << setw(25) << "INT_MIN: " << bs << endl << endl; int32_t minus1 = -1; cout << dec << setw(25) << "int32_t(-1): " << minus1 << " " << hex << minus1 << endl; bs = -1; cout << setw(25) << "int32_t(-1): " << bs << endl << endl; cout << dec << setw(25) << "UINT_MAX: " << UINT_MAX << " " << hex << UINT_MAX << endl; bs = UINT_MAX; cout << setw(25) << "UINT_MAX: " << bs << endl << endl; return 0; }