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 数据类型之间的区别


基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01