3.14-1 类型详述


  • 上溢出 / 下溢出
#include 
#include 

int main()
{
    std::cout << sizeof(int) << "\n";
    std::cout << std::numeric_limits::min() << "\n";
    std::cout << std::numeric_limits::max() << "\n";

    unsigned int x = 10;
    x = std::numeric_limits::max() + 1;  //上溢出
    std::cout << x << "\n";
    x = std::numeric_limits::min() - 1;  //下溢出
    std::cout << x << "\n";
}
  • 对齐信息
  • 内存 -> cache -> CPU, 按 cache line 为单位读写
  • 查看 cache line size:
/sys/devices/system/cpu/cpu0/cache/index0$ cat coherency_line_size
64