Difference between long and int data types(long 和 int 数据类型之间的区别)
问题描述
考虑到以下语句返回4,C++中的int和long类型有什么区别?
Considering that the following statements return 4, what is the difference between the int and long types in C++?
sizeof(int)
sizeof(long)
推荐答案
来自 this 参考:
一个 int 原本打算是的自然"字长处理器.许多现代处理器可以以相等的方式处理不同的字长轻松.
An int was originally intended to be the "natural" word size of the processor. Many modern processors can handle different word sizes with equal ease.
还有,这一点:
在许多(但不是全部)C 和 C++ 上实现,长大于一个整数.当今最流行的桌面平台,如 Windows 和 Linux,主要运行在 32 位处理器和这些平台的大多数编译器使用具有相同大小的 32 位 int并以长表示.
On many (but not all) C and C++ implementations, a long is larger than an int. Today's most popular desktop platforms, such as Windows and Linux, run primarily on 32 bit processors and most compilers for these platforms use a 32 bit int which has the same size and representation as a long.
这篇关于long 和 int 数据类型之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:long 和 int 数据类型之间的区别
基础教程推荐
- c++ STL设置差异 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
