#include <cstdint>
#include <iostream>
using namespace std;
int main()
{
cout << INT8_MIN << " " ; // -128
cout << INT16_MIN << " " ; // -32768
cout << INT32_MIN << " " ; // -2147483648
cout << INT64_MIN << "\n "; // -9223372036854775808
cout << (int)INT8_MAX << " " ; // 127: Without cast, output was a symbol.
cout << INT16_MAX << " " ; // 32767
cout << INT32_MAX << " " ; // 2147483647
cout << INT64_MAX << " " ; // 9223372036854775807
cout << endl;
return 0;
}
// Output:
// -128 -32768 -2147483648 -9223372036854775808
// 127 32767 2147483647 9223372036854775807
Reference: http://en.cppreference.com/w/cpp/types/integer
Monday, November 27, 2017
C++11: Fixed Width Integer Macro Constants
C++11 added fixed width integer macro constants. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment