#include <cstdint>
#include <iostream>
using namespace std;
int main()
{
cout << sizeof(int8_t ) << " "; // 1
cout << sizeof(int16_t ) << " "; // 2
cout << sizeof(int32_t ) << " "; // 4
cout << sizeof(int64_t ) << " "; // 8
cout << sizeof(int_fast8_t ) << " "; // 1
cout << sizeof(int_fast16_t ) << " "; // 4:fastest int at least 16 bits
cout << sizeof(int_fast32_t ) << " "; // 4
cout << sizeof(int_fast64_t ) << " "; // 8
cout << sizeof(int_least8_t ) << " "; // 1
cout << sizeof(int_least16_t) << " "; // 2:smallest int at least 16 bits
cout << sizeof(int_least32_t) << " "; // 4
cout << sizeof(int_least64_t) << " "; // 8
cout << sizeof(intmax_t ) << " "; // 8
cout << endl;
return 0;
}
// Output: 1 2 4 8 1 4 4 8 1 2 4 8 8
Reference: http://en.cppreference.com/w/cpp/types/integer
Monday, November 27, 2017
C++11: Fixed Width Integer Types
C++11 added fixed width integer types. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment