Minimum sizes for integral types

This question already has an answer here:

  • What does the C++ standard state the size of int, long type to be? 24 answers

  • 在这里输入图像描述

    The actual size of integer types varies by implementation. The standard only requires size relations between the data types and minimum sizes for each data type:

    The relation requirements are that the long long is not smaller than long , which is not smaller than int , which is not smaller than short . As char 's size is always the minimum supported data type, all other data types can't be smaller.

    The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits.


    To obtain the max/min number for each type you can call:

    #include <limits>
    const int min_int = std::numeric_limits<int>::min();
    const int max_int = std::numeric_limits<int>::max();
    

    or C solution:

    #include <limits.h>
    const int min_int = INT_MIN;
    const int max_int = INT_MAX;
    
    链接地址: http://www.djcxy.com/p/40404.html

    上一篇: 代表是标准的一部分?

    下一篇: 整型的最小尺寸